Writing unicode data in csv

前端 未结 2 1312
星月不相逢
星月不相逢 2020-12-21 04:14

I know similar kind of question has been asked many times but seriously i have not been able to properly implement the csv writer which writes properly in csv (it shows garb

相关标签:
2条回答
  • 2020-12-21 04:39

    Opening the file with codecs.open should fix it.

    0 讨论(0)
  • 2020-12-21 04:50

    You are writing a file in UTF-8 format, but you don't indicate that into your csv file.

    You should write the UTF-8 header at the beginning of the file. Add this:

    ff = open('a.csv', 'w')
    ff.write(codecs.BOM_UTF8)
    

    And your csv file should open correctly after that with the program trying to read it.

    0 讨论(0)
提交回复
热议问题