import csv
DATA=((10, 'Record 1', 'hi'),
(20, 'Record 2', 'bye'),
(30, 'Record 3', 'test'))
f=open('bookdata.csv', 'w')
writer=csv.writer(f)
writer=csv.writer(f,delimiter='\t',quotechar='"',quoting=csv.QUOTE_ALL)
for record in DATA:
writer.writerow(record)
f.close()
f=open('bookdata.csv', 'r')
reader=csv.reader(f)
for chap, title, pack in reader:
print("%s, %s, %s" % (chap, title, pack))
f.close()
它看起来对我来说是正确的,但它说“ValueError:需要超过 0 个值才能解压”
它确实阅读了第一行,但在阅读了第一行之后它崩溃了......
任何帮助,将不胜感激