摘要:
定义两个dict: dict_a = {"A": 123, "B": 456} dict_b = {"C": 11, "A": 234} 1. 按key取交集 dict_c = {k: v for k, v in dict_a.items() if k in dict_b.keys()} print 阅读全文
摘要:
1.差集 a = [1,2,3] b = [2,3] c = list(set(b).difference(set(a))) # b中有而a中没有的 2 .并集 c = list(set(a).union(set(b))) 3.交集 c=list(set(a).intersection(set(b) 阅读全文