标签:amp host add 去重复 print ict 数学 存储 vaule
demo_dict = {"key1":"value1","name":"xq","age":18}
键:值,键:值实例:
# dict
demo_dict = {"key1":"value1","name":"xq","age":18}
print(demo_dict)
print(type(demo_dict))
dict["键"]
# 通过键获取值 dict_vaule1 = demo_dict["age"] print(dict_vaule1)
dict.get(键)
# 通过get键获取值 value2 = demo_dict.get("name") print(value2)
键 in dict
# 判断键是否存在:in / get print("host" in demo_dict) print(demo_dict.get("host")) # 不存在返回None
pop(键)
值会跟着删除demo_set = set([1,2,3,4])
# set demo_set = set([1,2,3,5,6,3,2]) print(demo_set) # 会自动去重复
demo_set.add(值)
demo_set.remove(值)
&
、并集|
等操作:标签:amp host add 去重复 print ict 数学 存储 vaule
原文地址:https://www.cnblogs.com/thloveyl/p/11380075.html