python3.5 urllib.request.urlopen 中文url问题
来源:互联网 发布:淘宝宝贝属性是什么 编辑:程序博客网 时间:2024/04/28 13:42
https://www.zhihu.com/question/22899135
首先,url中的中文要单独处理,不能中英文全部合在一起处理(因为一部分的特殊字符也会被处理掉)。其次。在python3.0+中,已经不支持之前的urllib.quote了,而是需要urllib.parse.quote(str)一种可行的方案import urllibs=‘中文’s=urllib.parse.quote(s)url=’some english url character %s’%(s)urllib.request.urlopen(url)
作者:孙晓飞
链接:https://www.zhihu.com/question/22899135/answer/23746054
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
from urllib.parse import quote
import string
url = r’http://baike.baidu.com/item/人民的名义/17545218’
url = quote(url, safe = string.printable) # safe表示可以忽略的字符
print(url)
作者:知乎用户
链接:https://www.zhihu.com/question/22899135/answer/162163456
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
阅读全文
0 0
- python3.5 urllib.request.urlopen 中文url问题
- python3 urlopen打开包含中文的url
- python3关于urllib中urlopen报错问题的解决
- python3关于urllib中urlopen报错问题的解决
- urllib.urlopen已替换为urllib.request.urlopen()
- python3的urllib.request.urlopen()报certificate verify failed (_ssl.c:749)
- python3.3中urllib.request.open问题
- Python3 URLopen 含中文URL的处理方法
- python3中的urlopen对于中文url是如何处理的?
- Python3:urllib中urlopen()函数新特点
- Python3:urllib中urlopen()函数新特点
- python3 urllib.request
- Python3:urllib.request详解
- python3 标准库 urllib.request
- Python3: urllib.request 的使用
- python3 urlopen的解码问题
- python实例31[urllib.request.urlopen获取股票信息]
- 最基础的urllib.request.urlopen()基本使用
- 习题3.1(1)
- LuoguP3912 素数个数 解题报告【筛法求素数】
- 软件测试基础知识大全
- linux用户权限
- Linux rpm 常用命令
- python3.5 urllib.request.urlopen 中文url问题
- Spring MVC 异常处理
- ucosII移植笔记
- Linux教程【4】-Linux 系统目录结构
- linux-find
- maxRequestLength 文件上传限制大小的解决方法
- 使用jQuery编写AJAX
- 文章标题
- iTerm2