t = () #创建一个空元组
t = 'hair','blask','2,3',3 # t = ('hair', 'blask', '2,3', 3)
t = tuple() #创建一个空元组
t = ('hair', 'blask', (2,3), 3)
s = tuple(t) #对t进行一次浅拷贝,其他参数,尝试将对象转为tuple
my_list = [1,2] #my_list = [1, 2]
x = list() #x = []
y = list(list) #返回该参数的浅拷贝,对非list参数对象转换为列表
x = [1,1,1]
x[1] = 2 #x=[1, 2, 1]
names = ['Alice','Beth','Cecil','Dee-Dee','Earl']
del names[2] #names = ['Alice', 'Beth', 'Dee-Dee', 'Earl']
#替换长度相同的序列
name = ['P','e','r','l']
name[2:] = list('ar') #name = ['P', 'e', 'a', 'r']
#替换长度不同的序列
name = ['P','e','r','l']
name[1:] = list('ython') #name = ['P', 'y', 't', 'h', 'o', 'n']
#插入新元素
numbers = [1,5]
numbers[1:1] = [2,3,4] #numbers=[1, 2, 3, 4, 5]
numbers[::2] = [0,0,0] #numbers=[0, 2, 0, 4, 0]
s = set() # s = set()
s = set("Hello") #s = {'e', 'H', 'o', 'l'}
d5 = {'id':1948,'name':"Washer",'size':3} #d5 = {'id': 1948, 'name': 'Washer', 'size': 3}
d1 = dict({'id': 1948, 'name': 'Washer', 'size': 3})
d2 = dict(id = 1948, name= 'Washer', size = 3)
d3 = dict([('id',1948),('name','Wasther'),('size',3)])
-d.clear()
- d.copy()
- d.fromkey(s,v)
- d.get(k)
- d.items()
- d.keys()
- d.pop(k)
- d.pop(k,v)
- d.popitem()