TypeError: ‘_csv.reader‘ object is not subscriptable

遇事不要慌,先发个朋友圈

贴个代码

with open(filename) as csvfile:
    csvreader = csv.reader(csvfile)
    print(type(csvreader))
    for row in csvreader[1:] ##@#确定可以分片吗????????????
        data.append(row[-1])

import csv

然后reader出来的不是list or numpy.array

so 不支持分片;

data = []
with open(filename) as csvfile:
    csvreader = csv.reader(csvfile)
    print(type(csvreader))
    for row in csvreader:####确实不支持!!!!!!!!!!!
        data.append(row[-1])

可以借用个list导出来;

你可能感兴趣的:(python,其他,python)