开发者

How do I url unencode in Python?

开发者 https://www.devze.com 2022-12-20 14:48 出处:网络
Given this: It%27s%20me%21开发者_开发问答 Unencode it and turn it into regular text?in python2 >>> import urlparse

Given this:

It%27s%20me%21

开发者_开发问答

Unencode it and turn it into regular text?


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!"


Take a look at urllib.unquote and urllib.unquote_plus. That will address your problem. Technically though url "encoding" is the process of passing arguments into a url with the & and ? characters (e.g. www.foo.com?x=11&y=12).


Use the unquote method from urllib.

>>> from urllib import unquote
>>> unquote('It%27s%20me%21')
"It's me!"
0

精彩评论

暂无评论...
验证码 换一张
取 消