The content I got when crawling was like this b{"title":"u5173u6ce8","card_type_name":"u5173u6ce8"}, please tell me how to convert the encoding into Chinese characters
I found a method first follow_text = follow.text.encode('utf-8').decode('unicode-escape'),
The first response can be converted like this, but follow.text conversion will result in 'utf-8' codec can' t encode characters in position 2809-2810,
Then try to change it to text[:2809], no error will be reported, but there is still an error if you change it to text[2811:]
Use print(follow.text[2800:2810] )The output is '_image_url', I don’t know why the conversion failed
I would like to ask what the problem is, or is there any other way to convert the content I got
If
follow.text
本身是 str(unicode) 的话,encode('utf8') 回去没有任何意义,直接decode('unicode-escape')
that’s fineIf
follow.text
是 bytes 的话,那就可以选择先 decode('utf8') ,再decode('unicode-escape')
(assuming the correct encoding in your question is utf8)
You can just use json to decode it directly