set,三元,拷贝

# l1 = [11,22,33,44,11]
# a = set(l1)
# a.add(55)
# a.clear()
# print(a)
#
# l2 = {22,77,88}
# l3 = {11,22,33,44}
# b = l3.difference(l2)
# print(b)#a存在b不存在,并赋值给c
# l3.difference_update(l2)#更新a,返回none
# print(l3)
# l3.discard(11)#不报错
# l3.remove(44)
# print(l3)
# print(l2)
# l4 = l3.intersection(l2)#取交集,并赋值,updata是更新自己
# z = l3.isdisjoint(l2)#判断是否有交集,没交集返回True
# x = l3.issubset(l2)#判断是否是子集
# c = l3.issuperset(l2)#父集合
# print(z,x,c)
# ret = l2.pop()#移除最后一个,不报错,remove报错
# print(ret,l2)
# q = {11,22,33,44}
# w = {33,44}
# e = q.symmetric_difference(w)#对称交集,a存在b不存在,b存在a不存在的,赋值给e,updata是更新a
# print(e)
# r = q.union(w)#并
# print(r)
# w.update([55,66])#更新,后接可迭代
# print(w)
# def set_1():
# old_dict = {
# "#1": 11,
# "#2": 22,
# "#3": 100,
# }
# new_dict = {
# "#1": 33,
# "#4": 22,
# "#7": 100,
# }
# old_set = set(old_dict.keys())
# new_set = set(new_dict.keys())
# del_key = old_set.difference(new_set)
# add_key = new_set.difference(old_set)
# up_key = old_set.intersection(new_set)
# print(del_key,add_key,up_key)
# for up_keys in up_key:
# old_dict[up_keys] = new_dict[up_keys]
# print(old_dict)
# for add_keys in add_key:
# old_dict[add_keys] = new_dict[add_keys]
# print(old_dict)
# for del_keys in del_key:
# del old_dict[del_keys]
# print(old_dict)
# name ="ciahsd" if 1==2 else "asd"#三元运算
# print(name)
# str一次性创建,不能被修改,如果修改只能再创建
# list链表,下一个元素的位置,上一个元素的位置
import copy
# n1 = 123
# print(id(n1))
# n2 = n1
#由于python内部对数字和字符串的优化,无论如何拷贝赋值,字符串和数字的地址在内存中都不变
#对于列表,元组,字典,集合,其他,浅拷贝,copy.cpoy()只拷贝第一层,内存地址改变
#深拷贝除最后一层数字字符串,其他层都拷贝,内存地址都要改变

原文地址:https://www.cnblogs.com/currynashinians000/p/8590511.html