fp = open(f'captcha_{str(ran)}.jpg', 'wb')
fp.write(res.content)
@bot.callback_query_handler(func=lambda call:True)
func
говорит боту, когда вызывать обработчик. Бот вызывает только ОДИН обработчик (первый подходящий).func=lambda call:True
означает, что обработчик должен вызываться для ВСЕХ кнопок.item = types.InlineKeyboardButton('4', callback_data='foo.question1')
item2 = types.InlineKeyboardButton('3', callback_data='foo.question2')
gotov = types.InlineKeyboardButton('Готов', callback_data='bar.gotov')
@bot.callback_query_handler(func=lambda call:call.data.startswith('foo.'))
@bot.callback_query_handler(func=lambda call:call.data.startswith('bar.'))
callback_data='questions.q1.answer1'
). c.execute(f"SELECT * from banking_application WHERE name_p IS {pop}")
c.execute("SELECT * from banking_application WHERE name_p = ?", pop)
Но почему каша в serial, и как его ответ сделать только bytes без исключения, требует размышления и осознания. Ведь переменная a - это bytes, и binascii.hexlify(a) это тоже bytes...
b1 = bytes([1,2,3])
print(b1) # b'\x01\x02\x03'
# начиная с Python 3.8 можно указать разделитель в методе hex()
print(b1.hex(' ')) # 01 02 03
b2 = bytes([0x57, 0x54, 0x46])
print(b2) # b'WTF'
print(b2.hex(' ')) # 57 54 46
def partial(func: typing.Callable[[int, int], int], arg1: int) -> typing.Callable[[int], int]:
def wrapper(arg2: int) -> int:
return func(arg1, arg2)
return wrapper
def add (x: int, y: int) -> int:
return x + y
def div(x: int, y:int) -> int:
return x // y
add_42 = partial(add, 42)
print(add_42(3)) # 42 + 3 = 45
div_120 = partial(div, 120)
print(div_120(30)) # 120 // 30 = 4
def curry(func: typing.Callable[[int, int], int]) -> typing.Callable:
def wrapper(*args):
if len(args) == 2:
return func(*args)
elif len(args) == 1:
return partial(func, args[0])
else:
raise Exception('Invalid arguments')
return wrapper
curried_add = curry(add)
print(curried_add(32, 23)) # 55
add_30 = curried_add(30)
print(add_30(70)) # 30 + 70 = 100
PyCharm выдает ошибку No data sources are configured to run this SQL and provide advanced code assistance. Disable this inspection via problem menu
Но таблицу он создал и не дает ничего сделать с ней
Проблема в том что ридер зависает, ожидая следующую строчку
@bot.message_handler(commands=['start'])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard= True,)
item1 = types.KeyboardButton('Клик')
markup.add(item1)
bot.send_message(message.chat.id, f'Привет, {message.from_user. first_name}!', reply_markup=markup)
markup = ...
, уже не является частью функции startup(), так как отступ неверный. Учи Питон. steamcmd +force_install_dir ../somedir +login anonymous +workshop_download_item %1 validate +quit
getworkshop тут_id
steamcmd +force_install_dir "%2" +login anonymous +workshop_download_item %1 validate +quit
getworkshop тут_id тут\указываешь\каталог
locals()[numb + str(bomb_meaning)]
from os import environ
environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
import pygame # импорт строго после environ