python3 中采用 in 方法
1 #判断字典中某个键是否存在 2 arr = {"int":"整数","float":"浮点","str":"字符串","list":"列表","tuple":"元组","dict":"字典","set":"集合"} 3 #使用 in 方法 4 if "int" in arr: 5 print("存在") 6 if "float" in arr.keys(): 7 print("存在") 8 #判断键不存在 9 if "floats" not in arr: 10 print("不存在") 11 if "floats" not in arr: 12 print("不存在") 13