<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://howtodoinjava.com/python/dictionary-intersection/](https://howtodoinjava.com/python/dictionary-intersection/) Python 示例,用于查找 2 個或更多詞典之間的常見項目,即字典相交項目。 ## 1.使用“`&`”運算符的字典交集 最簡單的方法是查找鍵,值或項的交集,即使用兩個字典之間的 `&` 運算符。 ```py a = { 'x' : 1, 'y' : 2, 'z' : 3 } b = { 'u' : 1, 'v' : 2, 'w' : 3, 'x' : 1, 'y': 2 } set( a.keys() ) & set( b.keys() ) # Output set(['y', 'x']) set( a.items() ) & set( b.items() ) # Output set([('y', 2), ('x', 1)]) ``` ## 2.`Set.intersection()`方法 `Set.intersection()`方法返回一個集合,該集合包含集合`a`和集合`b`中都存在的項。 ```py a = { 'x' : 1, 'y' : 2, 'z' : 3 } b = { 'u' : 1, 'v' : 2, 'w' : 3, 'x' : 1, 'y': 2 } setA = set( a ) setB = set( b ) setA.intersection( setB ) # Output # set(['y', 'x']) for item in setA.intersection(setB): print item # Output #x #y ``` 請問有關**檢查兩個字典在 python 中是否具有相同的鍵或值**的問題。 學習愉快!
                  <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>

                              哎呀哎呀视频在线观看