Best way to convert a Unicode URL to ASCII (UTF-8 percent-escaped) in Python?

前端 未结 5 1523
情话喂你
情话喂你 2020-12-12 13:30

I\'m wondering what\'s the best way -- or if there\'s a simple way with the standard library -- to convert a URL with Unicode chars in the domain name and path to the equiva

5条回答
  •  渐次进展
    2020-12-12 14:11

    the code given by MizardX isnt 100% correct. This example wont work:

    example.com/folder/?page=2

    check out django.utils.encoding.iri_to_uri() to convert unicode URL to ASCII urls.

    http://docs.djangoproject.com/en/dev/ref/unicode/

提交回复
热议问题