1、讀取excel數(shù)據(jù),輸出為list各墨,使用csv_reader
使用官網(wǎng)上的實例
import csv
with open('world_alcohol.csv','rb') as f:
reader = csv.reader(f)
for line in reader:
print(line)
得到的結(jié)果:
Error: iterator should return strings, not bytes (did you open the file in text mode?)
最后發(fā)現(xiàn)應該這樣:
import csv
with open('world_alcohol.csv') as f:
world_alcohol = list(csv.reader(f))
print(world_alcohol)
不能加'rb'?不太理解逛裤,是為記瘩绒。