urlencode
???????,???URL?????????????????Python?,????? urllib.parse.quote
? urllib.parse.unquote
???? urlencode
????
??????? urllib.parse.quote
????????????:
from urllib.parse import quote url = "https://www.example.com/search?q=??,??!" encoded_url = quote(url, safe=':/?=') print(encoded_url)
????:
https://www.example.com/search?q=你好,世界!
??????,???? quote
???URL??????safe
????????????????,??????? ':/?=',???????????
????????????URL,???? urllib.parse.unquote
??:
from urllib.parse import unquote encoded_url = "https://www.example.com/search?q=你好,世界!" decoded_url = unquote(encoded_url) print(decoded_url)
????:
https://www.example.com/search?q=??,??!
??,?????? urlencode
????????