<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                #### len() \>>> a \['hello', 'world'\] \>>> len(a) 2 #### + 連接兩個序列 \>>> a \['hello', 'world'\] \>>> b=\["hello","python"\] \>>> a+b \['hello', 'world', 'hello', 'python'\] \>>> \*,重復元素 \>>> a=\['hello', 'world'\] \>>> a\*3 \['hello', 'world', 'hello', 'world', 'hello', 'world'\] \>>> in 判斷是否存在該元素 \>>> "hello" in a True \>>> "hi" in a False \>>> #### 判斷大小 \>>> a=\["azzz","zaaa"\] \>>> max(a) 'zaaa' \>>> b=\[2,4,5,5,3,2,6,8,1\] \>>> min(b) 1 \>>> #### append,extend追加元素 S.append() \>>> a=\["hello world"\] \>>> a.append("hello python") \#將括號里的元素追加到列表的尾部 \>>> a \['hello world', 'hello python', 'hello python'\] \>>> a.append(a) \>>> a \['hello world', \['hello python'\]\] \>>> \>>> a.append(a) \>>> a \['hello world', \[...\]\] #將自身列表添加到自身里,將出現這樣的循環 \>>> a=\['hello'\] \>>> b=\['world'\] \>>> a.append(b) \>>> a \['hello', \['world'\]\] \#將列表追加到列表末尾,帶列表符號\[ \] S.extend() #列表合并 \>>> a=\['hello'\] \>>> b=\['world'\] \>>> a.extend(b) \#將一個列表的元素追加到另一個列表 不帶列表符號\[ \] \>>> a \['hello', 'world'\] \>>> #### remove ,pop刪除元素 \>>> a \['hello', 'world'\] \>>> a.remove("hello") \>>> a \['world'\] \>>> a \['hello', 'world', 'hha'\] \>>> a.pop(2) \#pop(i) 刪除指定位置的值,若i超出列表長度則報錯 'hha' \#若不指定刪除的具體位置pop()表示刪除最后一個元素 \>>> a \['hello', 'world'\] \>>> #### count計數 \>>> q=\[1,23,34,4,45,6,67,342,2,5,56,8,96,21,1\] \>>> q \[1, 23, 34, 4, 45, 6, 67, 342, 2, 5, 56, 8, 96, 21, 1\] \>>> q.count(1) \#計算某個元素在列表中出現的次數 2 \>>> q.count(2) 1 \>>> q.count(4) 1 #### inde 確定元素位置 \>>> q \[1, 23, 34, 4, 45, 6, 67, 342, 2, 5, 56, 8, 96, 21, 1\] \>>> q.index(2) 8 \>>> q.index(1) 0 \>>> q.index(1) 0 \>>> q.index(4) 3 \>>> #### insert 插入元素 \>>> a \['world'\] \>>> a.insert(0,"hello") #insert(i,x) 在什么位置,插入什么元素,位置編號從0開始 \>>> a \['hello', 'world'\] \>>> \>>> a.insert(8,"hha") \#插入元素時插入位置若超過列表的最大長度,則默認插入到最后面 \>>> a \['hello', 'world', 'hha'\] \>>> #### reverse 反轉 \>>> a \['hello', 'world'\] \>>> a.reverse() \#reverse和\[::-1\]反轉效果的區別 \>>> a \['world', 'hello'\] \>>> a \['hello', 'world'\] \>>> a\[::-1\] \# reverse是反轉后將結果保存,再次輸出就是反轉后的結果 \['world', 'hello'\] \# 而\[ : :-1 \]是做一次反轉操作,并不會保存結果,輸出還是反轉前的結果 \>>> a \['hello', 'world'\] \>>> #### sort()排序 \>>> a=\[1,2,5,6,3,8,5,2,8,2,9,2\]3 \>>> a.sort() \>>> a \[1, 2, 2, 2, 2, 3, 5, 5, 6, 8, 8, 9\] \#sort()默認是從小到大排序 \>>> \>>> a.sort(reverse=True) \#實現從大到小排序 \>>> a \[9, 8, 8, 6, 5, 5, 3, 2, 2, 2, 2, 1\] \>>> (8) **列表和字符串的異同** 列表和字符串有很多相似之處,大多數操作方式在兩者上都能適用 下面說說他們的差異之處
                  <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>

                              哎呀哎呀视频在线观看