Python调用谷歌翻译接口
- 安装
- 翻译
- 语法识别
- 语种缩略表示
- 官方文档
安装
pip install googletrans
翻译
from googletrans import Translator
translator = Translator(service_urls=['translate.google.cn',])# 如果可以上外网,还可添加 'translate.google.com' 等
trans=translator.translate('Hello World', src='en', dest='zh-cn')
# 原文
print(trans.origin)
# 译文
print(trans.text)
语法识别
detection=translator.detect('All with Love')
print(detection.lang)
语种缩略表示
LANGUAGES = {'af': 'afrikaans','sq': 'albanian','am': 'amharic','ar': 'arabic','hy': 'armenian','az': 'azerbaijani','eu': 'basque','be': 'belarusian','bn': 'bengali','bs': 'bosnian','bg': 'bulgarian','ca': 'catalan','ceb': 'cebuano','ny': 'chichewa','zh-cn': 'chinese (simplified)','zh-tw': 'chinese (traditional)','co': 'corsican','hr': 'croatian','cs': 'czech','da': 'danish','nl': 'dutch','en': 'english','eo': 'esperanto','et': 'estonian','tl': 'filipino','fi': 'finnish','fr': 'french','fy': 'frisian','gl': 'galician','ka': 'georgian','de': 'german','el': 'greek','gu': 'gujarati','ht': 'haitian creole','ha': 'hausa','haw': 'hawaiian','iw': 'hebrew','hi': 'hindi','hmn': 'hmong','hu': 'hungarian','is': 'icelandic','ig': 'igbo','id': 'indonesian','ga': 'irish','it': 'italian','ja': 'japanese','jw': 'javanese','kn': 'kannada','kk': 'kazakh','km': 'khmer','ko': 'korean','ku': 'kurdish (kurmanji)','ky': 'kyrgyz','lo': 'lao','la': 'latin','lv': 'latvian','lt': 'lithuanian','lb': 'luxembourgish','mk': 'macedonian','mg': 'malagasy','ms': 'malay','ml': 'malayalam','mt': 'maltese','mi': 'maori','mr': 'marathi','mn': 'mongolian','my': 'myanmar (burmese)','ne': 'nepali','no': 'norwegian','ps': 'pashto','fa': 'persian','pl': 'polish','pt': 'portuguese','pa': 'punjabi','ro': 'romanian','ru': 'russian','sm': 'samoan','gd': 'scots gaelic','sr': 'serbian','st': 'sesotho','sn': 'shona','sd': 'sindhi','si': 'sinhala','sk': 'slovak','sl': 'slovenian','so': 'somali','es': 'spanish','su': 'sundanese','sw': 'swahili','sv': 'swedish','tg': 'tajik','ta': 'tamil','te': 'telugu','th': 'thai','tr': 'turkish','uk': 'ukrainian','ur': 'urdu','uz': 'uzbek','vi': 'vietnamese','cy': 'welsh','xh': 'xhosa','yi': 'yiddish','yo': 'yoruba','zu': 'zulu','fil': 'Filipino','he': 'Hebrew'
}
官方文档
https://py-googletrans.readthedocs.io/en/latest/
Python调用谷歌翻译接口相关推荐
- Python 调用谷歌翻译(2021年3月测试可用)
前言 把之前的用来谷歌翻译的Python文件整理了下, 用来处理翻译下i18n.js所需要的字典, 直接调用即可.2021年3月测试可用 (¦3[▓▓] 2021年9月17日 测试失效 请查看: Py ...
- python调用谷歌翻译英文文献pdf_Python 调用 Google Translate API 批量翻译文章
有时候批量翻译中文文章,批量变成各个小语种的语言,手动的粘贴复制是非常慢的.需要调用翻译 API 接口,综合对比市面上的各个翻译 API,个人觉得 Google 的翻译 API 最为好用和准确. 下面 ...
- python调用谷歌翻译__201907
2019年7月4日15:53:17(¦3[▓▓] 晚安 谷歌翻译环境 Python 3.6 第三方库 Execjs (pip install PyExecJS) 文件列表 同目录下的四个文件:- to ...
- 转:利用python调用谷歌翻译API
废话少说 从速卖通抓取了一些评论想进行一些简单的文本分析,但是因为速卖通是一个跨境电商平台,上边的评论基本都是小语种,对,小语种,俄语,法语...英语还可以勉强应付一下,但是其他真的是一个字母都不认识 ...
- python调用谷歌翻译Googletrans接口
1. 使用场景 快速翻译一些爬取的英文文章或段落 2. pip install pip install googletrans 3. 调用 3.1 英译汉 from googletrans impor ...
- Python 调用百度翻译接口实现翻译
小编分别写过有道,百度的翻译Demo,个人感觉有这么几个区别: 代码量:百度更简洁,有道太冗余: 是否收费:有道翻译免费,百度翻译超过一定量是要收费的,所以要验证key: 规范性:相比有道翻译,百度翻 ...
- php调用谷歌翻译接口_一个google翻译的php调用方式
直接看代码<?php /** * translate() * * 翻译函数 * * @param mixed $text 待翻译的内容 * @param string $language 翻译的 ...
- python 调用谷歌翻译
# -*- coding: UTF-8 -*- import requests import json from fake_useragent import UserAgent # from bs4 ...
- java调用谷歌翻译接口_Java 调用 google 翻译
1.Java代码 public class Translator { public String translate(String langFrom, String langTo, String wo ...
最新文章
- 爸爸和无我编程十条诫律
- Android之Android触摸事件传递机制
- 在线安装非GPU版的tensorflow流程
- AdvFlow:一种基于标准化流的黑盒攻击新方法,产生更难被发觉的对抗样本 | NeurIPS‘20
- 使用vi/vim编辑时按ctrl-s后客户端假死解决方法
- RxJS switchMap, mergeMap, concatMap,exhaustMap 的比较
- @Resource注解研究和在SAP Hybris ECP中的应用
- [Linux学习笔记] Linux历史发展与应用
- Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
- php strcmp函数用法,php字符串比较函数用法小结(strcmp,strcasecmp,strnatcmp及strnatcasecmp)...
- 7.Linux 高性能服务器编程 --- Linux 服务器程序规范
- python吃显卡还是内存条_用游戏本打游戏是显卡重要还是内存重要?
- UE4官方文档阅读笔记——蓝图可视化编程
- ORACLE SQL日期函数
- abaqus2017安装后启动cae报错_超详细Abaqus2017安装教程
- magicbook16使用心得,小技巧
- android bugly qq,Android如何快速集成腾讯Bugly
- 【5G核心网】5GC核心网之网元AUSF
- G2Plot 图例(legend)带瞄准图标解决
- 赖大师新文章 :Xilinx 开箱-KV260相机,两个小时轻松搞定,文章不能用我坐飞机过去帮你调哈。
热门文章
- 上海交通大学计算机学院导师介绍,上海交通大学计算机科学与工程系导师教师师资介绍简介-张同珍副教授...
- 网络:TCP与UDP
- 云服务ftp服务器搭建_如何在阿里云服务器搭建FTP服务器,在本地电脑连接并操作...
- 安卓 SDK 开发使用 VirtualAPK 实现插件化
- 企业微信版本更新(4.0.0.6003)
- 年赚千万的京东无货源被禁止?天猫店群如愿当上一哥
- 暴走gif失落的出处_暴走gif表情包 - 暴走gif微信表情包 - 暴走gifQQ表情包 - 发表情 fabiaoqing.com...
- 广积粮筑高墙缓称王[写给求职的刚毕业的]
- Layui.open 弹出上传图片、视频预览
- tcl多媒体面试 java_TCL面试经验