【发布时间】:2021-08-23 12:40:55
【问题描述】:
我正在尝试使用 Python 3 的 requests 库通过 DeepL API 传递多个文本变量,但目前还无法将多个文本参数传递给请求。 documentation 声明“在一个请求中最多可以提交 50 个文本参数”,但在尝试使用 "&text": 和常规 "text": 键传递多个文本变量后,该调用仅返回一个翻译。
作为参考,这是我使用的代码:
two_s = r.post(url="https://api.deepl.com/v2/translate", data={"target_lang": "EN", "auth_key": auth_key, "text": s2t1, "text":s2t2})
和
two_s = r.post(url="https://api.deepl.com/v2/translate", data={"target_lang": "EN", "auth_key": auth_key, "text": s2t1, "&text":s2t2})
其中 auth_key 是我的身份验证密钥,s2t1 和 s2t2 是不同的“字符串 2 翻译”。如何使用 Python 将多个 "text": 参数传递给 DeepL API?
【问题讨论】:
标签: python-3.x python-requests machine-translation deepl