python3 requests use quote instead of quote_plus

前端 未结 1 1158
Happy的楠姐
Happy的楠姐 2021-02-08 20:13

I use Python 3 and the requests module/library for querying a REST service.

It seems that requests by default uses urllib.parse.quote_plus() for urlencodin

相关标签:
1条回答
  • It turns out you can!

    from requests.utils import requote_uri
    url = "https://www.somerandom.com/?name=Something Cool"
    requote_uri(url)
    
    'https://www.somerandom.com/?name=Something%20Cool'
    

    documentation here The requote_uri method is about halfway down the page.

    0 讨论(0)
提交回复
热议问题