为了账号安全,请及时绑定邮箱和手机立即绑定

显示 response = rullib.request.urlopen(req) NameError: name 'rullib' is not defined求解

显示 response = rullib.request.urlopen(req) NameError: name 'rullib' is not defined求解

衣旧过不好这一生 2016-06-23 09:57:47
import urllib.requestimport urllib.parseimport jsoncontent = input('请输入需要翻译的内容:')url = "http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=dict2.index"data = {}data['type'] = 'AUTO'data['i'] = contentdata['doctype'] = 'json'data['xmlVetsion'] = '1.6'data['keyfrom'] = 'fanyi.web'data['ue'] = 'UTF-8'data['typoResult'] = 'true'data = urllib.parse.urlencode(data).encode('utf-8')req = urllib.request.Request(url, data)response = rullib.request.urlopen(req)html = response.read().decode('utf-8')target = json.loads(html)target = target['translateResult'][0][0]['tgt']print(target)
查看完整描述

1 回答

已采纳
?
清波

TA贡献165条经验 获得超90个赞

倒数第五句里面 urllib.request.urlopen(req) 拼写错误, 写成了 rullib.request.urlopen(req)

查看完整回答
2 反对 回复 2016-06-23
  • 1 回答
  • 0 关注
  • 2554 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信