我正在使用Python3的DeepL库尝试通过Python传递多个文本变量,但到目前为止还无法将多个文本参数传递给请求。文档声明“最多可以在一个请求中提交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转换”。如何使用"text":将多个DeepL参数传递给DeepL API?
发布于 2021-06-05 23:23:56
可以将元组列表作为data属性传递。
经过一些回显服务的测试后,它似乎与同一“键”的几个值一起工作。
r.post(
url="https://api.deepl.com/v2/translate",
data=[
("target_lang", "EN"),
("auth_key", auth_key),
("text", s2t1),
("text", s2t2),
]
)https://stackoverflow.com/questions/67854519
复制相似问题