集合
‘‘‘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))
时间: 2024-10-25 23:43:04