num_1 = None
num_2 = None
effect = None
while True:
if num_1 is None:
input_value = input("Введите первое число: ")
if input_value.isdigit():
num_1 = int(input_value)
else:
print('Вы ввели не число!')
continue
if num_2 is None:
input_value = input("Введите второе число: ")
if input_value.isdigit():
num_2 = int(input_value)
else:
print('Вы ввели не число!')
continue
if effect is None:
input_value = input(
"Напишите что вы хотите сделать (отнять, прибавить, умножить, разделить, возвести в степень, целое деление, остаток от деления): ")
if input_value in ("+", "-", "*", "/", "**", "//", "%"):
effect = input_value
break
else:
print('Нету такого действия!')
continue
# Выполнение операции
if effect == "+":
print(num_1 + num_2)
elif effect == "-":
print(num_1 - num_2)
elif effect == "*":
print(num_1 * num_2)
elif effect == "/":
print(num_1 / num_2)
elif effect == "**":
print(num_1 ** num_2)
elif effect == "//":
print(num_1 // num_2)
elif effect == "%":
print(num_1 % num_2)
config.getint("User", "id")
возвращает тип int, а у данного типа нет метода (атрибута) 'send'.user_id.send("Ваша заявка была одобрена")
вызовет ошибку выше.user = await bot.fetch_user(user_id: int)
await user.send(message)
import torch
torch.cuda.is_available()
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
print(device)
model = MyModel(args)
model.to(device)
l = []
for i in range(3):
l.append(lambda: i)
print([f() for f in l])
>>> [2, 2, 2]
l = []
for i in range(3):
l.append(lambda i = i : i)
print([f() for f in l])
>>> [0, 1, 2]
while True:
try:
x = pa.locateCenterOnScreen(r"C:\Python Scripts\library\proga.png", confidence=0.5)
print(x)
except Exception as e:
print(e)
len_pass_numbers.lower()
(и прочие) возвращает вам строку 'да', а вы сравниваете с 'Да'. chars
- пустой.from string import digits, ascii_lowercase, ascii_uppercase, punctuation
import requests
url = 'https://texttospeech.ru/api/v1/login'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0',
'Content-Type': 'text/plain;charset=UTF-8',
}
data = {"email": "sample@email.com", "pass": "password", "captcha": ""}
session = requests.Session()
response = session.post(url, json=data)
print(response.text)
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0',
'Content-Type': 'text/plain;charset=UTF-8',
}
def get_token() -> str:
url = 'https://texttospeech.ru/api/v1/login'
data = {"email": "sample@email.com", "pass": "password", "captcha": ""}
with requests.Session() as session:
response = session.post(url, headers=headers, json=data)
token = response.json().get('data').get('token')
return token
headers['token'] = get_token()
def synthesize(text: str) -> None:
url = 'https://texttospeech.ru/api/v1/synthesize'
data = {"rate": "0", "pitch": "0", "volume": "0", "hertz": "0", "shift": "0", "echo": "0",
"text": f'{text}',
"code": "ru-RU009",
"format": "mp3"}
with requests.Session() as session:
response = session.post(url, headers=headers, json=data)
if response.status_code == 200:
print(response.json().get('message'))
filelink = response.json().get('data').get('filelink')
with open(f'{text[0:10]}.mp3', 'wb') as file:
response = session.get(f'https://texttospeech.ru/{filelink}', headers=headers)
file.write(response.content)
else:
print(response.text)
synthesize('Привет мир')
on_component
- это не атрибут бота, а внутреннее событие.# Обработчик нажатия на кнопку присоединения к игре
@bot.event
async def on_component(interaction):
global players
if interaction.author not in players:
players[interaction.author] = None
await interaction.response.send_message(content=f"{interaction.author.mention} присоединился к игре!",
ephemeral=True)
else:
await interaction.response.send_message(content="Вы уже присоединились к игре!", ephemeral=True)
intents = disnake.Intents.all()
from requests_html import HTMLSession
def download(url):
session = HTMLSession()
resp = session.get(url)
resp.html.render()
if resp.status_code == 200:
list_of_img = resp.html.find('img')
d = list_of_img[0].attrs
image_url = d['srcset'].split(',')[-1].split(' ')[0]
image_name = image_url.split('/')[-1]
image = session.get(image_url).content
with open(image_name, 'wb') as file:
file.write(image)
else:
print(f"[ERROR] Не удалось загрузить изображение:\n{url}")
session.close()
download('https://scrolller.com/i-dragged-my-brother-out-at-1am-to-see-the-aogsmn8ihx')