1. 首页
  2. 数据库
  3. 其它
  4. python使用百度翻译进行中翻英示例

python使用百度翻译进行中翻英示例

上传者: 2021-02-23 23:38:58上传 PDF文件 25.93KB 热度 10次
利用百度词典进行中翻英 复制代码 代码如下:import urllib2import reimport sys reload(sys)sys.setdefaultencoding(‘utf-8’)def tran(word): url=’http://dict.baidu.com/s?wd={0}&tn=dict’.format(word) print url req=urllib2.Request(url) resp=urllib2.urlopen(req) resphtml=resp.read() text = re.search(r’explain:
下载地址
用户评论