我試圖定義一個新的格式:蟒蛇 - 類型錯誤: 「引用」 必須是整數
import csv
f = open("file.csv")
reader = csv.reader(f)
class my_dialect(csv.Dialect):
lineterminator = '\n'
delimiter: ';'
quotechar: '"'
reader = csv.reader(f, dialect=my_dialect)
輸出:
TypeError Traceback (most recent call last)
<ipython-input-121-0a8ad3677c01> in <module>()
----> 1 reader = csv.reader(f, dialect=my_dialect)
TypeError: "quoting" must be an integer
從技術文檔:
Dialect.quoting Controls when quotes should be generated by the writer and recognised by the reader. It can take on any of the QUOTE_* constants (see section Module Contents) and defaults to QUOTE_MINIMAL.
那是什麼意思?
這甚至不是有效的Python。 – chepner
如果你只是使用'csv',不知道爲什麼這個標籤是熊貓。 –
您需要導入並使用'QUOTE_MINIMAL'的常量值,或其他 –