很抱歉提交这么小的问题,但它让我疯了.我有这一行永久给我语法错误:
print(BDF) if header is 1
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
print(BDF) if (header == 1)
Run Code Online (Sandbox Code Playgroud)
这是完整的功能:
def CSVtoDict(BDF, prune, header):
# Comes with the option to prune [] and to use headers
with open('%s%s.csv' % (dataDir,BDF), mode='r') as infile:
reader = csv.reader(infile)
saved = {}
for row in reader:
key = row[0]
saved[key] = [r for r in row[1:] if not (r is '' and prune is 1)]
print(BDF) if header is 1
return saved
Run Code Online (Sandbox Code Playgroud)
什么可能导致这个?我正在调用函数:
adsMut = CSVtoDict(BaseDataFiles[0],1,1)
Run Code Online (Sandbox Code Playgroud)
一切似乎都井井有条,每次都只给我语法错误.