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'))

  

posted @ 2017-04-21 14:25  Jeremy Wu  阅读(333)  评论(0编辑  收藏  举报