Python: convert string from UTF-8 to Latin-1

前端 未结 4 1357
栀梦
栀梦 2021-02-12 14:36

I feel stacked here trying to change encodings with Python 2.5

I have XML response, which I encode to UTF-8: response.encode(\'utf-8\'). That is fine, but t

4条回答
  •  一个人的身影
    2021-02-12 15:14

    If the previous answers do not solve your problem, check the source of the data that won't print/convert properly.

    In my case, I was using json.load on data incorrectly read from file by not using the encoding="utf-8". Trying to de-/encode the resulting string to latin-1 just does not help...

提交回复
热议问题