【发布时间】:2022-11-10 23:26:12
【问题描述】:
我正在使用 Telebot 创建一个 Telegram Bot。
bot.get_me()
get_me() 与 Telegram Bot Api 中的 getme() 相同。
我需要得到机器人的名字。
上面的代码给了我:
{
"id":5519834543,
"is_bot":true,
"first_name":"BOTtle",
"username":"SomethingnotsurewhatBot",
"last_name":"None",
"language_code":"None",
"can_join_groups":true,
"can_read_all_group_messages":false,
"supports_inline_queries":false
}
在 Telegram Bot Api 的文档中,它说 getme() 返回一个 JSON 对象:https://core.telegram.org/bots/api#available-types
我如何要求它只返回first_name 或username?
【问题讨论】:
-
有什么理由不能从该字典中按键获取 first_name 吗?
-
你不能,只是解析 JSON 来获取你需要的数据/