- 36
- 0
来自Google Cloud Client Libraries官方文档:https://googlecloudplatform.g...
from google.cloud import translate
client = translate.Client()
client.translate(['Me llamo Jeff', 'My name is Jeff'],target_language='de')
代码执行结果:
C:\Python27\lib\site-packages\google\auth\_default.py:66: UserWarning: Your application has authenticated using end user
credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your app
lication continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled"
error. For more information about service accounts, see https://cloud.google.com/docs/authentication/.
warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
Traceback (most recent call last):
File "C:\Code\Google\test\run.py", line 15, in <module>
target_language=target)
File "C:\Python27\lib\site-packages\google\cloud\translate_v2\client.py", line 233, in translate
method='POST', path='', data=data)
File "C:\Python27\lib\site-packages\google\cloud\_http.py", line 293, in api_request
raise exceptions.from_http_response(response)
google.api_core.exceptions.Forbidden: 403 POST https://translation.googleapis.com/language/translate/v2: Your applicatio
n has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported b
y the translate.googleapis.com. We recommend that most server applications use service accounts instead. For more inform
ation about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/.
而如果在cmd下执行的话,可以正常执行
>>> from google.cloud import translate
>>> client = translate.Client()
>>> client.translate(['Me llamo Jeff', 'My name is Jeff'],target_language='de')
[{u'translatedText': u'Mein Name ist Jeff', 'input': 'Me llamo Jeff', u'detected
SourceLanguage': u'es'}, {u'translatedText': u'Mein Name ist Jeff', 'input': 'My
name is Jeff', u'detectedSourceLanguage': u'en'}] 0
打赏
收藏
点击回答
网站公告
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
