在Python中,有多種方法可以創建字典:
my_dict = {"key1": "value1", "key2": "value2"}
my_dict = dict(key1="value1", key2="value2")
my_dict = dict([("key1", "value1"), ("key2", "value2")])
keys = ["key1", "key2"]
default_value = 0
my_dict = dict.fromkeys(keys, default_value)
my_dict = {key: value for key, value in zip(keys, values)}
這些方法可以根據具體的需求和數據源選擇適合的方式創建字典。