python使用百度翻译进行中翻英示例
时间:2021-04-08 20:10:11
利用百度词典进行中翻英
import urllib2
import re
import 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: "(.*)"',resphtml)
return text.group(1).replace('<br />',' ')
a=tran('word')#要翻译的词
ab = open('resault.txt','w')
ab.write(a)
ab.close()
标签:python,翻译
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实现一键整理百度云盘中重复无用文件
2023-09-23 04:33:38
![](https://img.aspxhome.com/file/2023/7/93957_0s.png)
python+matplotlib演示电偶极子实例代码
2021-07-09 12:52:35
![](https://img.aspxhome.com/file/2023/3/77673_0s.jpg)
解决python3.6用cx_Oracle库连接Oracle的问题
2023-06-12 02:38:46
![](https://img.aspxhome.com/file/2023/7/59827_0s.png)
如何使用Python处理HDF格式数据及可视化问题
2023-11-21 00:17:01
![](https://img.aspxhome.com/file/2023/1/86651_0s.png)
PHP平滑关闭/重启的实现方法
2023-10-05 08:48:29
Python中return函数返回值实例用法
2023-11-19 02:11:36
Python 中的异步 for 循环示例详解
2021-07-09 10:27:30
Python中fnmatch模块的使用详情
2021-06-14 20:50:18
编写和优化SQL Server的存储过程
2009-04-13 10:13:00
AJAX打造博客无刷新搜索
2007-08-23 08:48:00
一个css垂直水平居中布局,css效果
2008-11-03 11:40:00
asp javascript picasa相册外链批量导出
2011-03-30 10:52:00
使用xml http为网站增加域名查询功能
2008-05-29 13:42:00
IE 8 提出“超级标准模式”
2008-01-24 19:26:00
Python使用QQ邮箱发送Email的方法实例
2021-03-25 11:33:57
![](https://img.aspxhome.com/file/2023/6/95526_0s.png)
django template实现定义临时变量,自定义赋值、自增实例
2021-05-24 09:16:46
python编写暴力破解FTP密码小工具
2021-11-29 15:32:40
python内置函数之eval函数详解
2022-07-22 12:39:29
可能是最全面的 Python 字符串拼接总结【收藏】
2023-10-06 14:29:20
Python自动生成代码 使用tkinter图形化操作并生成代码框架
2021-04-26 08:47:30
![](https://img.aspxhome.com/file/2023/7/95607_0s.jpg)