'ascii' codec can't encode character u'\u2013' in position 9: ordinal not in range(128)

后端 未结 2 1568
自闭症患者
自闭症患者 2021-01-12 16:06

I\'m trying to import to cvs, but I get this error

UnicodeEncodeError at /brokers/csv/\'ascii\' codec can\'t encode character u\'\\u2013\' in position 9: or         


        
相关标签:
2条回答
  • 2021-01-12 16:46

    Are you using lib cStringIO? I ran into a similar problem after replacing StringIO with cStringIO. Going back to StringIO was the solution.

    Furthermore, you can try using

    from __future__ import unicode_literals
    

    as the first line of your code.

    0 讨论(0)
  • 2021-01-12 16:50

    I'm guessing your using python 2.x?

    if so try using .encode('utf-8') on your string when writing.

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