string到字节,试图用列表打开一个CSV文件。 python

import csv date = [] open_price = [] high = [] low = [] close = [] volume = [] adj_close = [] with open(r'C:\Users\bruno.rojas\Desktop\Python_Data\SPX_Prices.csv') as f: reader = csv.reader(f) for row in reader: date.append(row[0]) open_price.append(row[1]) high.append(row[2]) low.append(row[3]) close.append(row[4]) volume.append(row[5]) adj_close.append(row[6]) date = str(date).encode() open_price = open_price open_prices = dict(zip(date, open_price)) high_prices = dict(zip(date, high)) low_prices = dict(zip(date, low)) close_prices = dict(zip(date,close)) volume_prices = dict(zip(date, volume)) adj_close_prices = dict(zip(date, adj_close)) with open('output.csv', 'wb') as output: writer = csv.writer(output) writer.writerow(date) 

我试图最终将每个字典发送到自己的Excel表,但我遇到了不能将我的列表转换为字节样式对象,尽pipe使用.encode函数的问题我只是试图在这个例子中输出一个列表。 TypeError:需要类似字节的对象,而不是“str”