select * from users, orders, items, commands, cats
select * from users u join orders o on u.user_id = o.user_id
sorted(self.students, key=lambda x: sum(x.grades))
while True:
try:
n = int(input('N = '))
break
except ValueError:
pass
print(n)
from PIL import Image, ImageDraw
img = Image.new("RGB", (800, 800))
idraw = ImageDraw.Draw(img)
idraw.pieslice([10,10,200,200], start=0, end=270, fill=None, outline="yellow")
img.show()
import re
categories = {
r"(время|времени|час)": "время",
r"(зовут|имя)": "имя",
}
# тестовые вопросы
questions = ["Сколько времени?", "Какой час?", "Время", "Как тебя зовут?", "Как твоё имя?"]
for question in questions:
for pattern, category in categories.items():
if re.search(pattern, question, re.I):
print(f"{question} = {category}")
root=Tk()
root.geometry('1000x1000')
img=Label(image=phot)
img.image=phot
gl.add_widget(Button(text='=',on_press = self.calc_result))
def calc_result(self, instance):
"UPDATE users SET user_name = COALESCE(?, user_name), user_surname = COALESCE(?, user_surname), username = COALESCE(?, username), phone_number = COALESCE(?, phone_number) WHERE id = ?"
SET user_name = COALESCE(NULLIF(?, ''), user_name),
...
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
x -= velocity
if event.key == pygame.K_RIGHT:
x += velocity
if event.key == pygame.K_UP:
y -= velocity
if event.key == pygame.K_DOWN:
y += velocity
# здесь же и проверка на выход из программы
elif event.type==pygame.QUIT:
run = False
pygame.quit()
quit()
screen.blit(player_img,(x,y))
from pyproj import Transformer
transformer = Transformer.from_crs("epsg:3857", "epsg:4326", always_xy=True)
x1,y1 = ('4702932.98067679','6656376.87212693')
x2,y2 = transformer.transform(x1, y1)
print (x2,y2)
import pandas as pd
data = {
"слово": 1,
"не": 2,
"воробей": 30
}
df = pd.DataFrame(data.items(), columns = ['word', 'value'])
print(df)
df[df['interval'] == 'До внедрения роботов']
cur.execute("SELECT COUNT(*) FROM users WHERE {} == 1".format(mmml))
или
cur.execute(f"SELECT COUNT(*) FROM users WHERE {mmml} == 1")
@bot.message_handler(commands=["api_id"])
def api_id(m, res=False):
bot.send_message(m.chat.id, 'Введите Api ID, полученное на сайте my.telegram.org')
@bot.message_handler(func=lambda message: True, content_types=['text'])
def msg(message):
print(message.text)
f = open('C:/Users/асер/Desktop/python/bot/api_id.txt', 'a')
f.write(message.text + '\n')
f.close()
bot.send_message(m.chat.id, 'Прекрасно!')
@bot.message_handler(commands=["api_id"])
def api_id(m, res=False):
bot.send_message(m.chat.id, 'Введите Api ID, полученное на сайте my.telegram.org')
# указываем запуск следующего шага обработки - свою функцию
bot.register_next_step_handler(message, get_api_id)
def get_api_id(message):
print(message.text)
with open('C:/Users/асер/Desktop/python/bot/api_id.txt', 'a') as f:
f.write(message.text + '\n')
bot.send_message(m.chat.id, 'Прекрасно!')
...
for row in result:
singup = str(row[0])
return singup
...
for row in result:
return str(row[0])
return row[0]
from dataclasses import fields
def combine(elements):
data = {field.name: sum([getattr(elem,field.name) for elem in elements],[]) for field in fields(elements[0])}
return Element(**data)
a = Element(...)
b = Element(...)
...
c = combine([a, b])
import datetime
my_date = datetime.datetime.now()
my_string = my_date.isoformat()
print(my_string)
date_from_string = datetime.datetime.fromisoformat(my_string)
print(date_from_string)