本帖最后由 冥界3大法王 于 2020-12-2 13:44 编辑
https://fanyi.caiyunapp.com/#/api
令牌我已经申请下来了。
[Python] 纯文本查看 复制代码 def tranlate(source, direction):
import requests
import json
url = "http://api.interpreter.caiyunai.com/v1/translator"
#WARNING, this token is a test token for new developers, and it should be replaced by your token
token = "3975l6lr5pcbvidl6jl2"
payload = {
"source" : source,
"trans_type" : direction,
"request_id" : "demo",
"detect": True,
}
headers = {
'content-type': "application/json",
'x-authorization': "token " + token,
}
response = requests.request("POST", url, data=json.dumps(payload), headers=headers)
return json.loads(response.text)['target']
source = ["Lingocloud is the best translation service.","彩云小译は最高の翻訳サービスです"]
target = tranlate(source, "auto2zh")
print(target)
土豹子不会玩。 求指点迷津,谢谢。
大饭桶一个,没学过post
顶上说的 执行下述 BASH 命令创建命令行工具 xiaoyi.sh 听不明白。。。 |