解码 URL 中的转义字符
我有一个列表,其中包含带有转义字符的 URL。这些字符已由 urllib2.urlopen 在恢复 html 页面时设置:
http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&action=edit
http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&action=history
http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&variant=zh
有没有办法将它们转换回 python 中的未转义形式?
PS: URL 编码为 utf-8
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(5)
情场扛把子 2024-12-22 15:18:12
或urllib.unquote_plus
>>> import urllib
>>> urllib.unquote('erythrocyte+membrane+protein+1%2C+PfEMP1+%28VAR%29')
'erythrocyte+membrane+protein+1,+PfEMP1+(VAR)'
>>> urllib.unquote_plus('erythrocyte+membrane+protein+1%2C+PfEMP1+%28VAR%29')
'erythrocyte membrane protein 1, PfEMP1 (VAR)'
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
使用
urllib
包(import urllib
):Python 2.7
来自 "="">官方文档:
Python 3
来自官方文档:
Using
urllib
package (import urllib
) :Python 2.7
From official documentation :
Python 3
From official documentation :