当我打印该行时,它会删除双引号,例如此csv:
a,“b”,c
打印像
['a', 'b', 'c']
但我想打印像
['a', '"b"', 'c']
蟒:
import csv
f_in = csv.reader (open('source.csv', 'rb'), quotechar='"')
fields = []
for line in f_in:
fields.append(line)
print line
任何想法?
由于
编辑:删除quotechar ='“'没有改变任何东西
答案 0 :(得分:0)
要将引号字符视为常规字符,请使用quoting=csv.QUOTE_NONE
import csv
f_in = csv.reader (open('source.csv', 'rb'), quoting=csv.QUOTE_NONE)
fields = []
for line in f_in:
fields.append(line)
print line