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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 公共方法 ## 1\. 運算符 | 運算符 | Python 表達式 | 結果 | 描述 | 支持的數據類型 | | --- | --- | --- | --- | --- | | + | \[1, 2\] + \[3, 4\] | \[1, 2, 3, 4\] | 合并 | 字符串、列表、元組 | | \* | \['Hi!'\] \* 4 | \['Hi!', 'Hi!', 'Hi!', 'Hi!'\] | 復制 | 字符串、列表、元組 | | in | 3 in (1, 2, 3) | True | 元素是否存在 | 字符串、列表、元組、字典 | | not in | 4 not in (1, 2, 3) | True | 元素是否不存在 | 字符串、列表、元組、字典 | #### + ~~~ >>> "hello " + "itcast" 'hello itcast' >>> [1, 2] + [3, 4] [1, 2, 3, 4] >>> ('a', 'b') + ('c', 'd') ('a', 'b', 'c', 'd') ~~~ #### \* ~~~ >>> 'ab' * 4 'ababab' >>> [1, 2] * 4 [1, 2, 1, 2, 1, 2, 1, 2] >>> ('a', 'b') * 4 ('a', 'b', 'a', 'b', 'a', 'b', 'a', 'b') ~~~ #### in ~~~ >>> 'itc' in 'hello itcast' True >>> 3 in [1, 2] False >>> 4 in (1, 2, 3, 4) True >>> "name" in {"name":"Delron", "age":24} True ~~~ **注意,in在對字典操作時,判斷的是字典的鍵** ## 2\. python內置函數 Python包含了以下內置函數 | 序號 | 函數 | 描述 | | --- | --- | --- | | 1 | len(item) | 計算容器中元素個數 | | 2 | max(item) | 返回容器中元素最大值 | | 3 | min(item) | 返回容器中元素最小值 | | 4 | del(item) | 刪除變量 | #### len ~~~ >>> len("hello itcast") 12 >>> len([1, 2, 3, 4]) 4 >>> len((3,4)) 2 >>> len({"a":1, "b":2}) 2 ~~~ **注意:len在操作字典數據時,返回的是鍵值對個數。** #### max ~~~ >>> max("hello itcast") 't' >>> max([1,4,522,3,4]) 522 >>> max({"a":1, "b":2}) 'b' >>> max({"a":10, "b":2}) 'b' >>> max({"c":10, "b":2}) 'c' ~~~ #### del del有兩種用法,一種是del加空格,另一種是del() ~~~ >>> a = 1 >>> a 1 >>> del a >>> a Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'a' is not defined >>> a = ['a', 'b'] >>> del a[0] >>> a ['b'] >>> del(a) >>> a Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'a' is not defined ~~~ ## 3\. 多維列表/元祖訪問的示例 ~~~ >>> tuple1 = [(2,3),(4,5)] >>> tuple1[0] (2, 3) >>> tuple1[0][0] 2 >>> tuple1[0][2] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: tuple index out of range >>> tuple1[0][1] 3 >>> tuple1[2][2] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range >>> tuple2 = tuple1+[(3)] >>> tuple2 [(2, 3), (4, 5), 3] >>> tuple2[2] 3 >>> tuple2[2][0] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not subscriptable ~~~
                  <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>

                              哎呀哎呀视频在线观看