Python: 字典dict: 相同点

问题:怎么样在两个字典中找相同点

answer

    eg1:

        下面2个字典

        a={'x':1,'y':2,'z':3},    b={'w':10,'x':11,'y':2},   

        1)找相同点: a.keys & b.keys()

   2)Find keys in a that are not in b: a.keys()-b.keys()

   3)过滤字典元素:c={key:a[key] for key in a.keys()-{'z','w'}}

           

原文地址:https://www.cnblogs.com/baxianhua/p/8078988.html