Python how to decode unicode with hex characters

后端 未结 3 682
Happy的楠姐
Happy的楠姐 2020-12-20 20:59

I have extracted a string from web crawl script as following:

u\'\\xe3\\x80\\x90\\xe4\\xb8\\xad\\xe5\\xad\\x97\\xe3\\x80\\x91\'

I want to d

3条回答
  •  無奈伤痛
    2020-12-20 21:30

    Just keep msg as string not unicode.

    msg = '\xe3\x80\x90\xe4\xb8\xad\xe5\xad\x97\xe3\x80\x91'
    result = msg.decode('utf8')
    

提交回复
热议问题