# 字典 score={"张三":"23","王五":"45"} print(score) dct=dict(name='张三',age='20') print(dict) print(type(score)) # 字典元素的获取 print(score['张三']) print(score.get('张三')) # 判断是否是字典中的元素 print('王五' in score) # 为字段字段赋值/新增 score['张三']='56' print(score) # 字典元素删除 del score['张三'] # 遍历字典中的元素keys values items for k,v in score.items(): print(k,v) # 生成字典 items=['张'] price= ['29'] new_dict={item.upper() for item,pric in zip(items,price)} print(new_dict) # 清空字典 # score.clear()