python url 中文
用urllib.request.urlopen(url) 打开有中文的网址的时候会报错
解决方法:
import urllib.parse
将中文 urllib.parse.quote("中文字符",encoding='GBK')
在调用urllib.request.urlopen(url)即可
即 strurl='http://'localhost/test.php?parm='+urllib.parse.quote("我是中文",encoding='GBK')
urllib.request.urlopen(strurl)
注意:urllib.parse.quote 里面只能是中文 如果吧链接都放进去 转换以后还是不能访问
2010年5月25日 02:22
如果不用encoding,直接用unicode不能正常运行么?
还有,sys.stdin.encoding可以自动判断当前python解释器使用的字符编码,我想如果用sys.stdin.encoding来替代"GBK",对程序的可移植性应该可以带来较大的好处。
个人拙见。
2015年9月11日 13:13
d
2018年12月29日 12:33
The topic you share is very good, I appreciate your sharing. Thank you!
2021年9月20日 18:14
Maids are specialists. Though they could be portrayed in different ways in motion pictures and about television, they expect ahead into your property, handle the particular cleaning, and also leave realizing they've pleased and stored you content. If you take the time to hire the proper professionals for your job, you may well be far happier with all the results as compared to you thought you will be. What steps in case you take before attracting a person to execute these tasks to suit your needs.
2022年8月24日 20:22
HPBOSE 12th New Question Paper 2023 Download, HPBOSE is popular knows as Himachal Pradesh Board Of School Education. HP Board Matric Important Question Paper 2023 It is one of the large board in India. Himachal Pradesh Board is going to conduct Class 12th annual examination for those candidates who have successfully registered for 12th boards exams in 2023.