1, the installation of related modules
Pip Install--upgrade Google-cloud
Or
Pip Install--upgrade google-cloud-translate
2, before invoking the API for translation, you need to install the relevant certificate
The official website provides the method to have three kinds: 1, installs the Google Cloud SDK downloading address
2, running in Google App Engine production
3, running in Google Compute Engine production
Because running locally, the first way to use, after installation there will be an automatic pop-up verification mailbox interface, if not in the Google Cloud SDK Shell run Gcloud auth application-default Login
3. Write Python program
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 '])
If you want to translate target = ' ru ' into target = ' ZH-CN ' reprint please specify: http://blog.csdn.net/u010856630/article/details/73810718