如何在python电报bot中写粗体 [英] How can I write bold in python telegram bot

查看:111
本文介绍了如何在python电报bot中写粗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用python写一个电报机器人.我想用粗体字母打印消息.我尝试使用*和**,但这无济于事. 是否有格式化功能或执行格式化的方法?

I am writing a telegram bot in python. I want to print messages with bold letters. I tried to use * and **, but it does not help. Is there a function for formatting or a way to do it?

推荐答案

您应使用:

bot.send_message(chat_id=chat_id, text="*bold* Example message", 
                parse_mode=telegram.ParseMode.MARKDOWN)

或者:

bot.send_message(chat_id=chat_id, text='<b>Example message</b>', 
                  parse_mode=telegram.ParseMode.HTML)

更多信息,请访问: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Code-snippets#message-formatting-bold-italic-code-

More info at: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Code-snippets#message-formatting-bold-italic-code-

这篇关于如何在python电报bot中写粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆