我正在尝试使用精彩的python-telegram-bot模块创建一个简单的Telegram Bot,但是我无法使字典与默认的"{0:<20} {1}".format(key, value)
想法保持一致。
让我举个例子:
MAP = {
"one": "1",
"two": "2",
"three": "3",
"four": "4",
"five": "5",
"six": "6",
"seven": "7",
"eight": "8"
}
tmpstring = ""
for key, value in MAP.items():
tmpstring = tmpstring + "{0:<20} {1}".format(key, value) + "\n"
print(tmpstring)
context.bot.send_message(chat_id=update.message.chat_id, text=tmpstring)
印刷后的外观如下:
one 1
two 2
three 3
four 4
five 5
six 6
seven 7
eight 8
如预期的那样完美地对齐,但是Telegram中的消息看起来像这样:
所以我的问题是: 如何调整聊天消息的外观,使其看起来像打印的输出?