Suppose I have the following string:
"http://earth.google.com/gallery/kmz/women_for_women.kmz?a=large"
Is there some function or module to be able to convert a string like the above to a string below where all the characters are changed to be compliant with a url:
"http%3A%2F%2Fearth.google.com%2Fgallery%2Fkmz%2Fwomen_for_women.kmz%3Fa%3Dlarge"
What is the best way to do this in python?
Python 2's urllib.quote_plus, and Python 3's urllib.parse.quote_plus
url = "http://earth.google.com/gallery/kmz/women_for_women.kmz?a=large" # Python 2 urllib.quote_plus(url) # Python 3 urllib.parse.quote_plus(url)
outputs:
'http%3A%2F%2Fearth.google.com%2Fgallery%2Fkmz%2Fwomen_for_women.kmz%3Fa%3Dlarge'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With