当然可以。在 Python 中,你可以使用如下方式为字典添加新的键值对:
dictionary = {'key1': 'value1'}
# 为字典添加新的键值对
dictionary['key2'] = 'value2'
print(dictionary) # 输出 {'key1': 'value1', 'key2': 'value2'}
当然可以。在 Python 中,你可以使用如下方式为字典添加新的键值对:
dictionary = {'key1': 'value1'}
# 为字典添加新的键值对
dictionary['key2'] = 'value2'
print(dictionary) # 输出 {'key1': 'value1', 'key2': 'value2'}