我有一个包含两列的文件,即
1 a 2 b 3 c
我希望将此文件读入字典,以便第1列是键,第2列是值,即
d = {1:'a', 2:'b', 3:'c'}
文件很小,因此效率不是问题.
python dictionary file
dictionary ×1
file ×1
python ×1