python3 csv 中文乱码【centos系统】

办法一

def writeData(self, movieList):
with open('81.csv', 'w', encoding='utf_8_sig', newline='') as f:
writer = csv.DictWriter(f, fieldnames=['content'])
writer.writeheader()
for each in movieList:
print(each)
writer.writerow(each)

 

办法二
import codecs
csvfile.write(codecs.BOM_UTF8)

posted @ 2019-02-23 12:24  字幕  阅读(241)  评论(0编辑  收藏  举报