我正在尝试读取s3存储桶中的csv文件,但出现错误。似乎有问题。list()import csvimport s3fsfs = s3fs.S3FileSystem(key='key', token='token', secret='secret')def open_csv(): with fs.open('way/to/my.csv', 'rb') as csv_file: csv_reader = list(csv.reader(csv_file)) return csv_reader原木:csv_reader = list(csv.reader(csv_file))_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
1 回答

哈士奇WWW
TA贡献1799条经验 获得超6个赞
删除字节(b)
用:
def open_csv():
with fs.open('way/to/my.csv', 'r') as csv_file:
csv_reader = list(csv.reader(csv_file))
return csv_reader
添加回答
举报
0/150
提交
取消