码迷,mamicode.com
首页 > 编程语言 > 详细

python 学习之路-day7

时间:2016-06-24 18:45:50      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

集合

‘‘‘
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

标签:

原文地址:http://www.cnblogs.com/zhanggs/p/5615010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!