python 调用Google Translate API 翻译
2017-06-27 17:59
337 查看
1、安装相关模块
或者
pip install --upgrade google-cloud-translate
2、调用api进行翻译之前,需要安装相关证书
官网提供的方法有三种:1、安装 Google Cloud SDK 下载地址
2、running in Google App Engine production
3、running in Google Compute Engine production
因为在本地上运行,使用的第一种方式,安装之后会有自动弹出验证邮箱的界面,如果没有在Google cloud sdk shell 运行
3、编写Python 程序
如果想要翻译成中文 把target =‘ru’ 改成 target = 'zh-CN'
转载请注明 :http://blog.csdn.net/u010856630/article/details/73810718
pip install --upgrade google-cloud
或者
pip install --upgrade google-cloud-translate
2、调用api进行翻译之前,需要安装相关证书
官网提供的方法有三种:1、安装 Google Cloud SDK 下载地址
2、running in Google App Engine production
3、running in Google Compute Engine production
因为在本地上运行,使用的第一种方式,安装之后会有自动弹出验证邮箱的界面,如果没有在Google cloud sdk shell 运行
gcloud auth application-default login
3、编写Python 程序
from google.cloud import translate translate_client = translate.Client() text = u'hello,world' target = 'ru' translation = translate_client.translate(text,target_language=target) print u'Text:{}'.format(text) print u'translation:{}'.format(translation['translatedText'])
如果想要翻译成中文 把target =‘ru’ 改成 target = 'zh-CN'
转载请注明 :http://blog.csdn.net/u010856630/article/details/73810718
相关文章推荐
- GOOGLE API - 翻译, 后台c# 调用前台js代码, asp.net后台调用js代码
- 【Python】Python的urllib、urllib2模块调用“百度翻译”API进行批量自动翻译
- 借助Google Translate API实现网站多国语言翻译功能
- 实践项目五:python调用百度API实现自动检测翻译
- Python3--批量爬取数据之调用百度api进行翻译
- 调用Google API做自己的翻译工具
- 【python】使用urllib,requests调google translate API
- python 调用Google Translate API进行翻译
- 使用 Google API 进行翻译的 Python 小工具
- 调用Google的API实现简单的翻译功能
- Python Google Translate API
- python调用google map api
- asp.net Google的translate工具翻译 API
- 利用python制作点读翻译软件(基于google api)
- 【3】python有道调用API进行翻译
- Google translate API 调用方法
- google api调用 实现在线翻译
- c#调用google api 实现google网站上翻译全功能(原创)
- asp.net Google的translate工具翻译 API
- 使用 Google API 进行翻译的 Python 小工具