1

How to display the text in the url: https://www.example.com?city=%u5B81%u6CE2&district=%u911E%u5DDE

The encoding of the page GB18030.

I tried to use html.unescape and urllib.parse.unquote but I cannot get the desired simplified Chinese characters.

What should I do?

If I have the text 常州 and 天宁 and want to convert it to the code %abcd%wxyz, what can I use?

Thanks.

John
  • 691
  • 1
  • 7
  • 20
  • 1
    Here is the solution: Question 1: "https://www.example.com?city=%u5B81%u6CE2&district=%u911E%u5DDE".replace("%", "\\").encode("utf-8").decode("unicode_escape") Question 2: '常州天宁'.encode("unicode_escape").decode("utf-8").replace('\\', '%') – Chan Mar 13 '19 at 10:39
  • It works. Thanks, Chan. – John Mar 13 '19 at 10:44

0 Answers0