Telegram makes tables croocked, how to make it appear as expected? Python aiogram

78 views Asked by At

the following piece of code

await message.answer(str(table))
await message.answer(str(summary), disable_notification=True)

makes the bot to answer with wierdly crooked tables (summary and table are exampliars of prettytable), how to fix it, I am aware of monospaced strings, but I don't quite get how it works and I do not know how to format a string to monospaced.

1

There are 1 answers

0
Dimon Agon On
await message.answer(f"```{table}```", 'Markdown')
await message.answer(f"```{summary}```", 'Markdown' disable_notification=True)

The answer was to put tables in tripple backticks that signalizes telegram to parse table to monospaced, also it is importaint to set parse mode to Markdown, so the string is read correctly