我有一些设置,我想添加到键盘标记。
some_set = {'2', '3', '0.2', '1'}
markup = types.ReplyKeyboardMarkup(one_time_keyboard=True)
markup.add(some_set)
msg = bot.send_message(message.from_user.id, "test", reply_markup=markup)
我得到了AttributeError: 'set' object has no attribute 'to_dic'
所以,我试图以愚蠢的方式做到这一点:
new_set = some_set[1:-1]
所以,它转向:screenshot
怎么做?
PS:使用telebot
答案 0 :(得分:0)
完成 它!
weights_keybord = set(weights)
for x in weights_keybord:
markup.row(x.replace("`", "").replace("\"", "").replace("'", ""))
msg = bot.send_message(message.from_user.id, """test """, reply_markup=markup)
答案 1 :(得分:0)
方法add将字符串作为输入,未设置
尝试一下:
some_set = {'2', '3', '0.2', '1'}
markup = types.ReplyKeyboardMarkup(one_time_keyboard=True)
for kb in some_set:
markup.add(kb)
msg = bot.send_message(message.from_user.id, "test", reply_markup=markup