系统相关
首页 > 系统相关> > python3 csv 中文乱码【centos系统】

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)

标签:writeData,centos,writer,乱码,each,csv,movieList
来源: https://www.cnblogs.com/zm-moon/p/10422248.html