小编Kly*_*ydd的帖子

如何通过 HTTP 向 Telegram 机器人发送文件?

我想通过 http Telegram API 发送文件并尝试以下代码:

def send_media(self, chat_id, doc):
    method = 'sendDocument'
    params = {'chat_id': chat_id, 'document': doc}
    resp = requests.post(self.api_url + method, params)
    return resp
 document = open('table.csv', 'rb')
 doc = InputFile(document)
 bot.send_media(last_chat_id, doc).json()
 document.close()
Run Code Online (Sandbox Code Playgroud)

并根据要求出现这样的错误:

 {'ok': False, 'error_code': 400, 'description': 'Bad Request: wrong URL host'}
Run Code Online (Sandbox Code Playgroud)

我应该怎么做才能发送文件?

python python-3.x python-requests telegram

2
推荐指数
1
解决办法
6125
查看次数

标签 统计

python ×1

python-3.x ×1

python-requests ×1

telegram ×1