Nav*_*jum 0 python dictionary
我有一个列表用作字典的键,并且对应于键的每个值都将初始化为0。
Rah*_*K P 9
你可以做 dict.fromkeys
dict.fromkeys
In [34]: dict.fromkeys(range(5),0) Out[34]: {0: 0, 1: 0, 2: 0, 3: 0, 4: 0} In [35]: dict.fromkeys(['a','b','c'],0) Out[35]: {'a': 0, 'b': 0, 'c': 0}
归档时间:
7 年,2 月 前
查看次数:
2651 次
最近记录: