from fastapi import FastAPI, Form
from typing import Optional
import uvicorn
from pydantic import BaseModel
fast_api = FastAPI()
class MyForm(BaseModel):
phone: Optional[str]
accountType: Optional[str]
@fast_api.post('/reg')
async def handler_response(data: MyForm):
print('phone', data.phone)
print('accountType', data.accountType)
return 'ok'
uvicorn.run(fast_api, host = '0.0.0.0', port = 80)
result = '7' in input()
class MyException(BaseException):
msg = 'Какаято ошибка'
def main():
...
raise MyException
def group(message):
global group
...
group = 1
@bot.message_handler(content_types=['text'])
def group(message):
...
_group = 1
group.groups[message.chat.id] = _group
...
group.groups = {}
bot.polling(none_stop=True)
x = lambda y: float(''.join([i for i in y if i.isdigit() or i == '.']))
print(x("ksrkfkkkedj 0.01 vkelrncksk"))
print(x('slkhjskljhksss342.921.khksjks'))
print(x('s,jhfskjyu932uio hi32n 89hnj3h287bn d98yn2.hiu3'))
class int2(int):
def __init__(self, x) -> None:
if not -32768 <= x <= 32767: raise TypeError
super().__init__()
import psycopg2
E = lambda field: f'$myseckey${field}$myseckey$' if type(field) is str else field
with connection.cursor() as cursor:
cursor.execute(
f"""INSERT INTO data(photo_avatar,
name,
type,
reach,
engagemant_er,
engage_percent)
VALUES ({E(profile_name)}, 'N\A', {E(reach)}, {E(engagement)}, {E(engage_per));"""
)
connection.commit()
from asyncio import create_task, run, sleep
async def thread_maintaining_communication(seconds: int):
while True: await sleep(seconds) ; print('тут')
async def main():
create_task(thread_maintaining_communication(20))
while True:
print('Сплю 10 сек')
await sleep(10)
run(main())
a = [[1,2,3], [4,5,6]]
res = [(x, y) for i in a for x in i for y in i]
print(res)