dicts = {}keys = range(4)values = ["Hi", "I", "am", "John"]for i in keys: dicts[i] = values[i]print(dicts)
或者
In [7]: dict(list(enumerate(values)))Out[7]: {0: 'Hi', 1: 'I', 2: 'am', 3: 'John'}
欢迎分享,转载请注明来源:内存溢出
dicts = {}keys = range(4)values = ["Hi", "I", "am", "John"]for i in keys: dicts[i] = values[i]print(dicts)
或者
In [7]: dict(list(enumerate(values)))Out[7]: {0: 'Hi', 1: 'I', 2: 'am', 3: 'John'}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)