#1---------列表
list = [123, 456]
print(list)
list.append(456)#末尾添加
print(list)
list.insert(0, 789) #位置添加
print(list)
list2 = [1, 2, 3]
list.extend(list2) #列表后面拼接
print(list)
list.reverse() #列表反转
print(list)
list.pop() #把list的最后一个数弹出并删掉
print(list)
list.sort() #把list升序排序
print(list)
#2--------------字典
d = [1, 2, 3, 4, 5]
dictA = dict.fromkeys(d)
print(dictA)
c = ['a', 'b', 'c', 'd', 'e']
dictB = dict(zip(d, c))
print(dictB.keys())
print(dictB.values())
dictB.setdefault(5, 'm') #设置默认值时若已存在 就不会设置
dictB.setdefault(6, 'f')
print(dictB)
dictC = {121: "abc"}
dictB.update(dictC)#在字典的后面更新
print(dictB)
results = dictB.items()
for result in results:
key, value = result
print(key, value)