`dict1={'name':'Lara','age':18}
判断键在不在字典中
for one in dict1:
if 'name' in dict1:#或dict1.keys()
print('key在字典中!')
break
判断值在不在字典中
for one in dict1:
if 'Lara' in dict1.values():
print('value在字典中!')
break`
2024-03-16 14:51:28
`dict1={'name':'Lara','age':18}
for one in dict1:
if 'name' in dict1:#或dict1.keys()
print('key在字典中!')
break
for one in dict1:
if 'Lara' in dict1.values():
print('value在字典中!')
break`