6
這裏是我到目前爲止的代碼:TypeError:'_csv.reader'對象沒有屬性'__getitem__'?
import csv
reader = csv.reader(open('new_file.txt','r'),delimiter=' ')
row1 = reader[0]
row2 = reader[1]
row3 = reader[2]
這裏是我的new_file.txt
:
this is row one
this is row two
this is row three
當我運行它,我有以下錯誤:
Traceback (most recent call last):
File "/home/me/Documents/folder/file.py", line 211, in <module>
row1 = reader[0]
TypeError: '_csv.reader' object has no attribute '__getitem__'
我怎樣才能解決這個問題?
謝謝。