but1= types.InlineKeyboardButton('Утром', callback_data='daypart|утро')
but2= types.InlineKeyboardButton('Днём', callback_data= 'daypart|день')
@bot.callback_query_handler(func=lambda call: call.data.split('|')[0]=='daypart')
with open('data.json') as f:
data = json.load(f)
class Author2(BaseModel):
name: str
class Book(BaseModel):
title: str
author2: Author2 | None
books = [Book(**book) for book in data]
markup = types.InlineKeyboardMarkup(row_width=8)
sq_s_g3 = f"SELECT * FROM '{player1}-{player2}'"
cursor.execute(sq_s_g3)
records = cursor.fetchall()
for row in records:
markup.add(types.InlineKeyboardButton(text = row[1], callback_data = row[0]))
def start(message):
# тут то, что должно отрабатывать при start
@bot.message_handler(commands=['start'])
def start_command(message):
start(message)
@bot.message_handler(commands=['starts'])
def starts_command(message):
start(message)
# Далее то, что должно отрабатывать при starts
@bot.message_handler(commands=['start', 'starts'])
def start_command(message):
# то, что должно обрабатываться при этих командах
def get_value_from_dict(dct, path):
if not path:
return
key = path[0]
new_path = path[1:]
if curr_value := dct.get(key, None):
if new_path:
if type(curr_value) == dict:
if new_path:
return get_value_from_dict(curr_value, new_path)
else:
return
else:
return curr_value
d={
"lvl1_1": {
"lvl2_1": {
"lvl3_1": "value",
"lvl3_2": {
"lvl4_1": "value"
},
"lvl2_2": "value"
}
}
}
print(get_value_from_dict(d, ["lvl1_1", "lvl2_1", "lvl3_2", "lvl4_1"]))
def find_nb(m):
summ = 0
i=0
while summ != m:
i+=1
summ += i**3
if summ > m:
return -1
return i
TypeError: countdown() missing 1 required positional argument: 'time'
root.after(1000, countdown, count-1)
root.after(1000, countdown, count-1, time)
@dp.callback_query_handler(lambda call: call.data.startswith("answer")