Google Translator 是最好的文本翻译工具之一,其 API 可用于多种编程语言。 因此,您可以用您选择的任何编程语言编写程序,将用某种语言编写的文本翻译成许多其他语言。 在本 Python 教程中,我们将解释如何使用 Google Translate API 用 Python 翻译语言。

我们将编写一个 Python 程序,该程序可以将给定的文本从一种语言翻译成另一种语言。 首先,我们需要为 Python 安装 Google Translate API 或 googletrans 库。
For English translation: Python language translator
安装 Python 谷歌翻译 API
要安装 Google Translate API,我们可以使用 pip install 命令后跟 Google Translate API 名称,即 googletrans:
pip install googletrans
如果不指定版本直接安装googletrans库,pip会为你的Python环境安装googletrans-3.0.0,这个版本存在一些bug。 因此,对于本教程,我们将安装 Python googletrans 库的预发布版本,即 4.0.0rc1。
运行以下 pip install 命令为您的 Python 环境安装 Google Translate API v4.0.0rc1:

本教程介绍了如何在Python中使用Google Translate API进行文本翻译。首先,通过pip安装googletrans库的预发布版本4.0.0rc1。接着,展示了如何列出API支持的所有语言,并编写Python程序将英语翻译成印地语,通过Translator模块实现翻译功能。
最低0.47元/天 解锁文章
2693





