<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國際加速解決方案。 廣告
                # Python `sum()`函數 > 原文: [https://thepythonguru.com/python-builtin-functions/sum/](https://thepythonguru.com/python-builtin-functions/sum/) * * * 于 2020 年 1 月 7 日更新 * * * `sum()`函數采用一個可迭代的并返回其中的項目總數。 **語法**: ```py sum(iterable, [start]) -> number ``` | 參數 | 描述 | | --- | --- | | `iterable`(必填) | 可迭代項,例如字符串,列表,字典等。 | | `start`(可選) | 一個可選的數值添加到最終結果中。 默認為`0`。 | `sum()`函數僅適用于數字值,嘗試將其用于非數字類型將導致錯誤。 這是一個例子: ```py >>> >>> sum([1, 2, 3, 4, 5]) # sum values in a list 15 >>> >>> sum((1, 2, 3, 4, 5)) # sum values in a tuple 15 >>> >>> sum({1, 2, 3, 4, 5}) # sum values in a set 15 >>> >>> sum({1: "one", 2: "two", 3: "three"}) # sum values in a 6 >>> ``` 試試看: ```py print(sum([1, 2, 3, 4, 5])) # sum values in a list print(sum((1, 2, 3, 4, 5))) # sum values in a tuple print(sum({1, 2, 3, 4, 5})) # sum values in a set print(sum({1: "one", 2: "two", 3: "three"})) # sum values in a ``` 在最后一個命令中,`sum()`將字典中的鍵添加進去,而忽略其值。 這是另一個示例,它指定要添加到最終結果中的`start`值。 ```py >>> >>> sum([10, 20, 30], 100) 160 >>> ``` 試一試: ```py print(sum([10, 20, 30], 100)) ``` * * * * * *
                  <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>

                              哎呀哎呀视频在线观看