标签:www enc encode color port 示例 print baidu 虚拟
1 import urllib.request 2 import urllib.parse 3 4 5 params = {‘name‘:‘张三‘,"age":"18",‘say‘:‘hello world‘} 6 result = urllib.parse.urlencode(params) 7 print(result) 8 result2 = urllib.parse.parse_qs(result) 9 print(result2) 10 11 #示例 12 url1 = ‘https://www.baidu.com/s?wd=‘ 13 params2 = {‘wd‘:‘虚拟环境‘} 14 url2 = urllib.parse.urlencode(params2) 15 url3 = url1 + ‘?‘ + url2 16 resp = urllib.request.urlopen(url3) 17 print(resp.readline())
标签:www enc encode color port 示例 print baidu 虚拟
原文地址:https://www.cnblogs.com/kogmaw/p/12506850.html