每日一模块-PyDeepLx免费翻译模块
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# datetime:2023/11/17
"""
一个第三方 DeepL 翻译的免费、不限量 API.
DeepLX 是一个开源项目,它基于 DeepL 免费服务,
将其转换为本地 API,提供给第三次程序使用,如沉浸式翻译、BOb。
github源码地址:https://github.com/OwO-Network/DeepLX/
python包:https://github.com/OwO-Network/PyDeepLX
pip install PyDeepLX
"""
from PyDeepLX import PyDeepLX
# 默认情况下,源语言会被自动识别并翻译成英文,而不会提供任何其他结果。
print(PyDeepLX.translate("你好世界")) # Return String
# Specify the source and target languages
# PyDeepLX.translate("你好世界", "ZH", "EN") # Return String
# # Need alternative results
# PyDeepLX.translate("毫无疑问的", "ZH", "EN", 2) # Return List: ['Without a doubt', 'No doubt']
#
# # Print the results
# PyDeepLX.translate("毫无疑问的", "ZH", "EN", True, True)
#
# # Using proxy
# PyDeepLX.translate(text="毫无疑问的", sourceLang="ZH", targetLang="EN", numberAlternative=0, printResult=False,
# proxies="socks5://127.0.0.1:7890")
人生苦短,我用python!