📜  交叉口 python dict - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:28.450000             🧑  作者: Mango

代码示例1
Python 3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = {'a': 123, 'c': 5}
>>> b = {'a': 2, 'b': 4}
>>> a.keys() & b.keys()  # intersection
{'a'}
>>> a.keys() ^ b.keys()  # difference
{'b', 'c'}
>>> a.keys() - b.keys()  # subtraction
{'c'}