When I use Chinese as URL parameter,it doesn't work with python -
url='https://www.bing.com/search?q=你好&qs=n&form=qblh&pq=你好&sc=2-0&sp=-1&sk=&cvid=8f0865226c' urllib.request.urlopen(url)
then console shows this:
you need encode double byte chars quote urllib.parse.
import urllib.request urllib.parse import quote url='https://www.bing.com/search?q=%s&qs=n&form=qblh&pq=%s&sc=2-0&sp=-1&sk=&cvid=8f0865226c'%(quote('你好'),quote('你好')) urllib.request.urlopen(url)
you can read more : how deal unicode string in url in python3?
Comments
Post a Comment