python google_api_translate.py
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python google_api_translate.py相关的知识,希望对你有一定的参考价值。
#!/usr/bin/python
# -*- coding: utf-8 -*-
from apiclient.discovery import build
from django.conf import settings
def translate(word, from_l, to_l):
if isinstance(word, unicode) is False:
word = unicode(word, 'utf-8')
service = build(
'translate',
'v2',
developerKey=settings.GOOGLE_API_KEY)
return service.translations().list(
source=from_l,
target=to_l,
q=[word]
).execute()['translations'][0]['translatedText']
以上是关于python google_api_translate.py的主要内容,如果未能解决你的问题,请参考以下文章
Python代写,Python作业代写,代写Python,代做Python
Python开发
Python,python,python
Python 介绍
Python学习之认识python
python初识