['*a*', '*b*', '*c*', '*d*', '*f*','*g*']
['11', '22', '33', '44', '', '55']
['66', '77', '88', '', '99', '10']
['23', '24', 'sac', 'cfg', 'dfg', '']
必要把在字典为:其被试过如上所示如何将多个列表转换为Python中的字典?
import csv
csvFile = csv.reader(open("sach.csv", "rb"))
for row in csvFile:
print row
代码, 行的输出被如上所示:
{a : ('11','66','23'),b : ('22','77','24'),c : ('33','88','sac'),d :('44','','cfg')}
行被从CSV文件中读取其中有许多名单。 请帮我把它放在字典格式,如上所示。通过在reader
对象通过与在CSV行*
参数Python会循环
with open("sach.csv", "rb") as csv_infile:
reader = csv.reader(csv_infile)
yourdict = {r[0].replace('*', ''): r[1:] for r in zip(*reader)}
的zip()
function为你做配对,并通过每行作为一个单独的参数zip()
:
在你的字典里,你需要把钥匙变成'a','a''还是''a *''? –