# определяем функцию, которая загружает расписание из файла
def load_schedule():
try:
... # реальная ошибку у тебя где-то здесь!
except FileNotFoundError: # но при ошибке ты глотаешь исключение и молча возвращаешь None
return None, None
def check_schedule2():
start_time, end_time = load_schedule()
... # а тут не проверяем, вернула ли функция значение или None
import re
from decimal import Decimal # не используй float для денег!
sum_regexp = re.compile(r'^((?:\D*\d+)+?)(?:\D+(\d{2}))?\D*$')
def string_to_sum(s: str) -> Decimal:
match = sum_regexp.match(s)
if match is None:
raise ValueError(f'Not a correct sum: {s!r}')
integer_part = re.sub(r'\D', '', match.group(1))
fraction = match.group(2) or '00'
fixed_string = f'{integer_part}.{fraction}'
return Decimal(fixed_string)
tests = {
'0': Decimal('0.0'),
'1000': Decimal('1000.0'),
'10.00': Decimal('10.0'),
'10,00': Decimal('10.0'),
'1 000': Decimal('1000.0'),
'1,000,000.00': Decimal('1_000_000.00'),
'1000 рублей 90 копеек': Decimal('1000.90'),
}
for inp, res in tests.items():
print(inp, end=': ')
try:
actual_res = string_to_sum(inp)
except ValueError as err:
print('Exception: ', err)
else:
if res != actual_res:
print('Mismatch, got', actual_res)
else:
print('OK')
import logging
from aiogram import Bot, Dispatcher, executor, types, utils
API_TOKEN = 'replace_this_with_your_api_token'
# Configure logging
logging.basicConfig(level=logging.INFO)
# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN, parse_mode="html")
dp = Dispatcher(bot)
def get_keyboard():
keyboard = types.ReplyKeyboardMarkup()
button = types.KeyboardButton("Share Position", request_location=True)
keyboard.add(button)
return keyboard
@dp.message_handler(content_types=['location'])
async def handle_location(message: types.Message):
lat = message.location.latitude
lon = message.location.longitude
reply = "latitude: {}\nlongitude: {}".format(lat, lon)
await message.answer(reply, reply_markup=types.ReplyKeyboardRemove())
@dp.message_handler(commands=['locate_me'])
async def cmd_locate_me(message: types.Message):
reply = "Click on the the button below to share your location"
await message.answer(reply, reply_markup=get_keyboard())
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
tail -f файл.log
. Почитай про неё.screen
. Тогда ты сможешь сконнектиться к сессии screen когда угодно./home/root
, и делаешь cd ../folder/folder2
, ты будешь пытаться перейти в каталог /home/folder/folder2
. for number in range(0, 1_000_000):
str_number = f'{number:0>6}' # превращаем число в строку, добивая нулями слева до 6 знаков
digits = list(map(int, str_number)) # каждый символ строки превращаем в отдельное число, т.е. цифру
d1, d2, d3, d4, d5, d6 = digits # распаковываем список цифр в отдельные переменные
for d1 in range(10):
for d2 in range(10):
for d3 in range(10):
for d4 in range(min(9, d1+d2+d3) + 1):
for d5 in range(min(9, d1 + d2 + d3 - d4) + 1):
d6 = d1 + d2 + d3 - d4 - d5
if 0 <= d6 <= 9:
print(f'{d1}{d2}{d3}{d4}{d5}{d6}')
for d1 in range(10):
for d2 in range(10):
for d3 in range(10):
min_d4 = max(0, d1 + d2 + d3 - 18)
max_d4 = min(9, d1 + d2 + d3)
for d4 in range(min_d4, max_d4 + 1):
min_d5 = max(0, d1 + d2 + d3 - d4 - 9)
max_d5 = min(9, d1 + d2 + d3 - d4)
for d5 in range(min_d5, max_d5 + 1):
d6 = d1 + d2 + d3 - d4 - d5
if 0 <= d6 <= 9:
print(f'{d1}{d2}{d3}{d4}{d5}{d6}')
Only days, seconds and microseconds are stored internally. Arguments are converted to those units:
A millisecond is converted to 1000 microseconds.
A minute is converted to 60 seconds.
An hour is converted to 3600 seconds.
A week is converted to 7 days.
timedelta(days=1).seconds
даст 0, так как это 1 день и 0 секунд.timeout = datettime.timedelta(days=1)
if (datetime.datetime.now() - last_command_use_time) > timeout:
...
timeout = datettime.timedelta(days=1)
if (datetime.datetime.now() - last_command_use_time).total_seconds() > 24*60*60:
...
_tkinter.TclError: bad option "-tittle": must be -default, -detail, -icon, -message, -parent, -title, or -type
File "c:\Users\Solo\Desktop\MAXIUMAM2035\Go_user.py", line 19, in button_click
messagebox.showinfo(tittle='Проверка', message=info_str) # Для вывода информации
^^^^^^