更新时间:2023-02-23 10:40:46
对于 python 2:
>>>导入 urllib2>>>打印 urllib2.unquote("%CE%B1%CE%BB%20")αλ对于python 3:
>>>从 urllib.parse 导入取消引用>>>打印(取消引用(%CE%B1%CE%BB%20"))αλ这里的代码适用于所有版本:
尝试:从 urllib 导入取消引用除了导入错误:从 urllib.parse 导入取消引用打印(取消引用(%CE%B1%CE%BB%20"))
Is there any way in Python to transform this %CE%B1%CE%BB%20
into this αλ
which is its real representation?
For python 2:
>>> import urllib2
>>> print urllib2.unquote("%CE%B1%CE%BB%20")
αλ
For python 3:
>>> from urllib.parse import unquote
>>> print(unquote("%CE%B1%CE%BB%20"))
αλ
And here's code that works in all versions:
try:
from urllib import unquote
except ImportError:
from urllib.parse import unquote
print(unquote("%CE%B1%CE%BB%20"))