Unicode Encoding Errors Python - Parsing XML can't encode a character (Star)

前端 未结 1 1438
轻奢々
轻奢々 2021-01-22 09:02

I am a beginner to Python and am currently parsing a web-based XML file from the eventful.com API however, I am receiving some unicode errors when retrieving certain elements of

1条回答
  •  伪装坚强ぢ
    2021-01-22 09:47

    Where are you using your decoding methods?

    I had this error in the past and had to decode the raw. In other words, I would try doing

    data = response.read()
    #closes file
    response.close()
    #decode
    data.encode("us-ascii")
    

    That is if it is in fact ascii. My point being make sure you are encoding/decoding the raw results while it is still in a string format, before you call parseString on it.

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