当前位置:   article > 正文

Python调用deepl api脚本

deepl api

1.需求安装

pip install deepl

1.1翻译完整脚本

因为deepl网页版有自动识别文本语种的功能,随意脚本中只需设置目标语言即可(target_language)。

英译中:

import deepl
def translation(strs):

    auth_key = "********"  # use DeepL free API 
    target_language = 'ZH'      #"EN-US"
    #调用deepl
    translator = deepl.Translator(auth_key)  #input the auth_key
    #print(time.time())

    result = translator.translate_text(strs,target_lang=target_language)
    return result.text
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/473748
推荐阅读
相关标签
  

闽ICP备14008679号