jeapedu 128 集合的習題2

链接: https://pan.baidu.com/s/1G4E90F62WV_8DTdwoN0_1Q 密码: vc5w

# 2 find common key in two dict
d1 = dict(a = 1, b = 2, c = 3)
d2 = dict(b = 3, d = 4, f = 5)
print(d1)
print(d2)
dk1 = d1.keys()
dk2 = d2.keys()
s1 = set(dk1)
s2 = set(dk2)
print(s1)
print(s2)
ss = s1.intersection(s2)
print(ss)
ss = s2.intersection(s1)
print(ss)
t = list()
for x in dk1:
    if x in dk2:
        t.append(x)
print(t)
阅读更多
个人分类: jeapedu
上一篇jeapedu 127 集合的習題1
下一篇jeapedu 129 集合的習題3
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭