Python: Write UTF-8 characters to csv file
To use codecs, we can write UTF-8 characters into csv file
import codecs with open('ExcelUtf8.csv', 'w') as f: t = u'晚上吃什么' f.write(codecs.BOM_UTF8) f.write('%s,1,3\n' % t.encode('utf-8'))
To use codecs, we can write UTF-8 characters into csv file
import codecs with open('ExcelUtf8.csv', 'w') as f: t = u'晚上吃什么' f.write(codecs.BOM_UTF8) f.write('%s,1,3\n' % t.encode('utf-8'))