python 学习之路-day7
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 学习之路-day7相关的知识,希望对你有一定的参考价值。
集合
‘‘‘
s1 = {"121231","23421342","241432"}
s2 = {"17283971829","2384908213904","121231"}
# print (s1.difference(s2))
# print (s1.symmetric_difference(s2))
# s1.difference_update(s2)
# print(s1)
li = [11,12,13,14,15]
s1.update(li)
print (s1)‘‘‘
old_dict = {
"#1":8,
"#2":4,
"#4":2,
}
new_dict = {
"#1":4,
"#2":4,
"#3":2,
}
old_set = set(old_dict.keys())
new_set = set(new_dict.keys())
remove_set = old_set.difference(new_set)
add_set = new_set.difference(old_set)
print (old_set.intersection(new_set))
以上是关于python 学习之路-day7的主要内容,如果未能解决你的问题,请参考以下文章