【发布时间】:2018-10-09 19:35:13
【问题描述】:
如何在 python 中以“文档”的其他文件名发送电报文档? 我正在使用 Python3。 “doc”是我想作为txt文件发送的明文。
url = baseurl + token + '/sendDocument'
dict = {'chat_id':chat_id}
r = requests.post(url, params=dict, files={'document':doc})
收到的文件名为“document”,没有文件扩展名。当我将文件重写为
files={'document.txt':doc}
电报回复
{"ok":false,"error_code":400,"description":"Bad Request: there is no document in the request"}
有人知道如何为文件设置文件名吗?
【问题讨论】:
-
为什么需要自定义文档名称?
-
这是关于 openvpn 配置文件的。它们应该具有与应用关联的结尾 .ovpn,并且不必由用户手动重命名。
标签: python telegram telegram-bot