我想在下面的csv文件閱讀:蟒蛇3 CSV文件 - 屬性錯誤
https://github.com/eljefe6a/nfldata/blob/master/stadiums.csv
我複製並粘貼的內容就到Excel並保存爲一個CSV文件,因爲它是在一個unix格式。
和我得到以下屬性錯誤信息
任何幫助表示讚賞。謝謝。
import sys
import csv
with open('stadium.csv', newline='') as csvfile:
readCSV = csv.reader(csvfile,delimiter=',')
for line in readCSV:
line = line.strip()
unpacked = line.split(",")
stadium, capacity, expanded, location, surface, turf, team, opened, weather, roof, elevation = line.split(",")
results = [turf, "1"]
print("\t".join(results))
錯誤:
Traceback (most recent call last):
File "C:/Python34/mapper.py", line 31, in <module>
line = line.strip()
AttributeError: 'list' object has no attribute 'strip'
我不知道爲什麼你再次分裂'line.split(「,」)' –