python - 如何使用 python bot 将本地 html 文件发送到 Telegram
问题描述
这是我的代码
file_address = './charts/candle_chart.html'
response = bot.sendDocument(chat_id=chat_id, document=file_address, timeout=timeout)
但我得到了异常host not found
错误
电报认为这个文件在网络上
有谁能够帮我!
解决方案
电报机器人的文档说:
The document argument can be either a file_id, an URL or a file from disk: open(filename, 'rb')
所以它必须是这样的:
html_file = open('./charts/candle_chart.html', 'rb')
response = bot.sendDocument(chat_id=chat_id, document=html_file, timeout=timeout)
有关更多信息,请参阅文档:
推荐阅读
- r - 通过R中的OCR从pdf读取文本
- flutter - GestureDetector 在 TabBarView 上不起作用
- ssl - 仅在本地计算机上:[SSL: CERTIFICATE_VERIFY_FAILED] _ssl.c:1108) 错误
- c - 控制流结构中没有指定返回语句的函数返回值
- angular6 - 每次 ngFor 迭代都有不同的组件视图
- nlp - 罗伯塔模型预处理文本的混淆
- flutter - GestureDetector 不适用于 Dismissible Widget
- .net - 允许有和没有 {culture} 的路由 (.net core 2.2)
- java - G Suite Admin SDK Directory API - 获取 ChromeOS 设备列表 - Java
- angular - 不推荐使用字符串作为事件,并将在未来的版本中删除