字典类似java中的map
例子:
dict = {'key1': 23, 'key2': 'value2'}
print(dict['key1'])
# 修改字典内容
dict['key2'] = 58
print(dict)
# 清空字典
dict.clear()
print(dict)
运行结果:
23
{'key1': 23, 'key2': 58}
{}
字典类似java中的map
例子:
dict = {'key1': 23, 'key2': 'value2'}
print(dict['key1'])
# 修改字典内容
dict['key2'] = 58
print(dict)
# 清空字典
dict.clear()
print(dict)
运行结果:
23
{'key1': 23, 'key2': 58}
{}