Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decode a (doubly) 'url-encoded' string in python

Tags:

People also ask

What does %2f mean in a URL?

URL encoding converts characters into a format that can be transmitted over the Internet. - w3Schools. So, "/" is actually a seperator, but "%2f" becomes an ordinary character that simply represents "/" character in element of your url. Follow this answer to receive notifications.

How do I decode a UTF-8 string in Python?

To decode a string encoded in UTF-8 format, we can use the decode() method specified on strings. This method accepts two arguments, encoding and error . encoding accepts the encoding of the string to be decoded, and error decides how to handle errors that arise during decoding.

How do I remove 20 from a URL in Python?

replace('%20+', '') will replace '%20+' with empty string.


Tried decoding a url-encoded string in the following way

some_string = 'FireShot3%2B%25282%2529.png' import urllib res = urllib.unquote(some_string).decode() res u'FireShot3+%282%29.png' 

Original string is FireShot3 (2).png. Any help would be appreciated.

Answer: urllib.unquote_plus(urllib.unquote_plus(some_string)) due to double encoding.