如何在 python 中使用 Telegram Bot 发送 Dataframe?

How to send a Dataframe with Telegram Bot in python?

所以我正在使用 Telegram Bot,它从 SQL 查询中获取数据并将结果发送给人们。

我曾尝试通过查询手动格式化数据 return,但这并不符合我的预期。我也尝试过使用 Telegram 的 Markdown 和 HTML 解析模式,但没有成功。

所以我现在想将查询的结果转换为数据帧(我已经这样做了),然后如何将数据帧发送到 python 中的电报机器人?

如果无法发送数据帧,那么有更好的方法吗?

非常感谢您的宝贵时间!

您最好的选择是生成 , or an from your dataframe. In my experience,生成图像是在所有客户端上始终获得格式正确 table 的唯一方法。