<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Python 元組 > 原文: [https://thepythonguru.com/python-tuples/](https://thepythonguru.com/python-tuples/) * * * 于 2020 年 1 月 7 日更新 * * * 在 Python 中,元組與列表非常相似,但是一旦創建了元組,就無法添加,刪除,替換和重新排序元素。 **注意**: 元組是不可變的。 ## 創建一個元組 * * * ```py >>> t1 = () # creates an empty tuple with no data >>> >>> t2 = (11,22,33) >>> >>> t3 = tuple([1,2,3,4,4]) # tuple from array >>> >>> t4 = tuple("abc") # tuple from string ``` ## 元組函數 * * * 元組也可以使用`max()`,`min()`,`len()`和`sum()`之類的函數。 ```py >>> t1 = (1, 12, 55, 12, 81) >>> min(t1) 1 >>> max(t1) 81 >>> sum(t1) 161 >>> len(t1) 5 ``` ## 元組迭代 * * * 元組可使用`for`循環進行迭代,[在此處了解有關 for 循環的更多信息](/python-loops/)。 ```py >>> t = (11,22,33,44,55) >>> for i in t: ... print(i, end=" ") >>> 11 22 33 44 55 ``` ## 元組切片 * * * 切片運算符在元組中的作用與在列表和字符串中的作用相同。 ```py >>> t = (11,22,33,44,55) >>> t[0:2] (11,22) ``` ## `in`和`not in`運算符 * * * 您可以使用`in`和`not in`運算符檢查元組中項的存在,如下所示。 ```py >>> t = (11,22,33,44,55) >>> 22 in t True >>> 22 not in t False ``` 在下一章中,我們將學習 [python 數據類型轉換](/datatype-conversion/)。 * * * * * *
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看