小编use*_*589的帖子

如何在python中将多个列表转换为字典?

['*a*', '*b*', '*c*', '*d*', '*f*','*g*']
['11', '22', '33', '44', '', '55']
['66', '77', '88', '', '99', '10']
['23', '24', 'sac', 'cfg', 'dfg', '']
Run Code Online (Sandbox Code Playgroud)

需要在字典中输入:

{a : ('11','66','23'),b : ('22','77','24'),c : ('33','88','sac'),d :('44','','cfg')}
Run Code Online (Sandbox Code Playgroud)

从CSV文件中读取行:

import csv
csvFile = csv.reader(open("sach.csv", "rb"))
for row in csvFile:
    print row
Run Code Online (Sandbox Code Playgroud)

上面显示的代码,上面显示的行的输出有很多列表.请帮我把它换成字典格式,如上图所示.

python csv parsing dictionary

1
推荐指数
1
解决办法
87
查看次数

标签 统计

csv ×1

dictionary ×1

parsing ×1

python ×1