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

                ##### 得到列表```list_x = [1,5,-3,-2,6,0,9]```中的正數 通常做法: ```python list_x = [1,5,-3,-2,6,0,9] res = [] for i in list_x: if(i > 0): res.append(i) print(res) ------------------------------------------ 輸出: [1, 5, 6, 9] ``` 一般做法:使用```filter```類和```lambda匿名函數``` ```python list_x = [1,5,-3,-2,6,0,9] x = filter(lambda x:x>0,list_x) print(x) ----------------------------------------- 輸出: [1, 5, 6, 9] ``` 使用列表解析,這種方法比前兩種執行速度更快。*推薦* ```python list_x = [1,5,-3,-2,6,0,9] x = [x for x in list_x if x>0] ------------------------------------------------ 輸出: [1, 5, 6, 9] ``` ##### 得出字典{'a':79,'b':89,'c':90}中值大于等于90的值 使用字典解析: ```python data = {'a':79,'b':89,'c':90,'d':92} d = {x:y for x,y in data1.items() if y>=90} print(d) ------------------------------------ 輸出: {'c': 90, 'd': 92} ``` ##### 篩選出集合{77,33,89,32,30}中能被3整除的元素 使用集合解析 ```python data = {77,33,89,32,30} d = {x for x in data2 if x %3 == 0} print(d) ------------------------------------------------ 輸出: {33, 30} ```
                  <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>

                              哎呀哎呀视频在线观看