|
发表于 2018-10-3 16:09:15
|
显示全部楼层
import urllib.request
import urllib.parse
url='http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
data={}
data['i']='爱'
data['from']='AUTO'
data['to']='AUTO'
data['smartresult']='dict'
data['client']='fanyideskweb'
data['salt']='1536822250178'
data['sign']='4637a8e847b4e2c6f783acb80a17f62d'
data['doctype']='json'
data['version']='2.1'
data['keyfrom']='fanyi.web'
data['action']= 'FY_BY_REALTIME'
data['typoResult']='false '
urllib.parse.urlencode(data).encode('utf-8')
response=urllib.request.urlopen(url,data)
html=response.read().decode('utf-8')
print(html)
代码会报错(TypeError: can't concat str to bytes)是什么原因?求大神解释以下 |
|