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:

enter image description here

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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -