嗨,有人可以告诉我为什么我的语法无效,最后一行出现在第二行“ 这是一个迭代CSV文件并将所有内容转换为十进制ASCII等效的脚本。谢谢
import csv
with open('C:\Users\user\Desktop\log_transformed_truncated.csv', 'w') as outfile:
c = csv.writer(outfile)
counter = 0
with open('C:\Users\user\Desktop\log.csv','rb') as f:
for row in csv.reader(f, delimiter=';'):
counter = counter + 1
mod_row = []
if counter != 1:
for cell in row:
mod_row.append(sum(bytearray(cell)))
else:
for cell in row:
mod_row.append(cell)
c.writerow(mod_row)
print "processed {} rows".format(counter)
答案 0 :(得分:0)
你忘了放括号,因为它是python 3的语法。
这句话对我有用:
print("processed {} rows".format(counter))
您还可以查看此answer以获取有关python 2和python 3中print语句之间差异的更多信息。