1. 程式人生 > >python3中的read中的next用法注意

python3中的read中的next用法注意

正確用法(python3中的用法)

allElectronicsData = open(r'C:/pydata/AllElectronics.csv', 'rt')

reader = csv.reader(allElectronicsData)

headers = next(reader)

錯誤用法(python2中的用法)

allElectronicsData = open(r'C:/pydata/AllElectronics.csv', 'rb')

reader = csv.reader(allElectronicsData)

headers = reader.next()