Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I url unencode in Python?

Given this:
It%27s%20me%21

Unencode it and turn it into regular text?

like image 495
TIMEX Avatar asked Feb 16 '10 23:02

TIMEX


People also ask

How do I encode a URL?

Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format. URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.

How do you pass special characters in a URL in Python?

s = urllib2. quote(s) # URL encode. # Now "s" is encoded the way you need it. It works!


1 Answers

in python2

>>> import urlparse
>>> urlparse.unquote('It%27s%20me%21')
"It's me!"

In python3

>>> import urllib.parse
>>> urllib.parse.unquote('It%27s%20me%21')
"It's me!"
like image 125
John La Rooy Avatar answered Sep 30 '22 12:09

John La Rooy