a = {
“x”:1,
“y”:2,
“z”:3
}
b = {
“x”:1,
“w”:11,
“z”:12
}
print(a.items())
dict_items([(‘x’, 1), (‘y’, 2), (‘z’, 3)])
查看两个字典共有的key
print(a.keys() & b.keys())
{‘x’, ‘z’}
查看字典a 和字典b 的不共有的key
print(a.keys() ^ b.keys())
{‘y’}
查看在字典a里面而不在字典b里面的key
print(a.keys() - b.keys())
{(‘x’, 1)}
查看字典a和字典b相同的键值对
print(a.items() & b.items())
{‘w’, ‘y’}