key的判断:
'''字典元素的判断'''
people = {'张三': 88, '李四': 55, '李明': 99}
print('张三' in people)
print('李明' not in people)
字典元素的删除:
people = {'张三': 88, '李四': 55, '李明': 99}
# print('张三' in people)
# print('李明' not in people)
# 字典元素的删除:删除指定的 key-value对
del people['张三']
print(people) # 删除之后,剩余:
字典元素的清空:
# 字典元素的清空
people.clear()
print(people)
字典元素的添加:
# 字典元素的添加:
people['赵鸣'] = 321
print(people)
字典元素的修改:
# 字典元素的修改
people['赵鸣'] = 123
print(people)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)