python使用百度翻译进行中翻英示例
2018-10-12 13:50
489 查看
利用百度词典进行中翻英
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使用百度翻译进行中翻英示例
- 使用python进行收据搜集示例之feature_engineering_example
- 使用Python进行AES加密和解密的示例代码
- Python使用MD5加密算法对字符串进行加密操作示例
- 使用python进行收据搜集示例之crawl_and_parse
- 使用python进行收据搜集示例之python_regular_expression
- 使用aespython进行ECB加解密示例
- 使用python进行收据搜集示例之different_format_data_processing
- SqlPager最终版[附源码和示例程序](使用存储过程进行分页)
- 使用server.transfer进行页面传值示例
- 使用Python进行验证码识别
- Python urlopen 使用小示例
- JavaScript 使用正则表达式进行表单验证的示例代码
- Java中使用SSHA对数据进行加密的示例
- 使用XMLHttprequest对象进行异步调用html页面的示例
- [Python学习]使用minidom来处理XML的示例 (一)–XML的读取
- [Python学习]使用minidom来处理XML的示例 (二)–XML的写入
- Python urlopen 使用小示例
- 使用SWIG和Python对C/C++进行单元测试(一)
- 使用 Python 进行线程编程