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

前端 未结 4 1451
栀梦
栀梦 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 14:57

    data="UTF-8 data"
    udata=data.decode("utf-8")
    data=udata.encode("latin-1","ignore")
    

    Should do it.

提交回复
热议问题