【发布时间】:2020-06-09 18:30:40
【问题描述】:
我已使用模块 3to2 将我的 python3 代码转换为 python2,但现在无法写入 CSV 文件。
TypeError: must be unicode, not str
转换后的代码
def writeCSV(self,filepath,data):
with open(filepath, u'a', newline=u'') as file:
writer = csv.writer(file)
writer.writerow(data)
传递的数据是['10/06/2020 04:28:57 AM', u'HCL Docker', u'Down'] .我可以知道如何解决这个问题吗?
【问题讨论】:
标签: list python-2.7 export-to-csv