Python: write a list with non-ASCII characters to a text file

前端 未结 4 1999
遥遥无期
遥遥无期 2021-02-08 15:22

I\'m using python 3.4 and I\'m trying to write a list of names to a text file. The list is as follows:

my_list = [\'Dejan Živković\',\'Gregg Berhalter\',\'James          


        
4条回答
  •  一向
    一向 (楼主)
    2021-02-08 16:15

    Try using UTF-8 encoding. You can start by putting # -- coding: utf-8 -- at the top of your .py file.

提交回复
热议问题