...
import sqlalchemy
def _lower(arg: str) -> str:
return arg.lower()
@sqlalchemy.event.listens_for(db.engine, "connect")
def on_connect(dbapi_connection, connection_record):
dbapi_connection.create_function("lower", 1, _lower)
pip install sqlite-icu
import sqlalchemy
import sqlite_icu
@sqlalchemy.event.listens_for(db.engine, "connect")
def on_connect(dbapi_connection, connection_record):
dbapi_connection.load_extension(sqlite_icu.extension_path().replace(".so", ""))
import vk_api
from key import token
vk = vk_api.VkApi(token=token)
vk._auth_token()
my_list = []
while True:
messages = vk.method(
"messages.getConversations",
{"offset": 0, "count": 20, "filter": "unanswered"},
)
if messages["count"]:
user_id = messages["items"][0]["last_message"]["from_id"]
message_text = messages["items"][0]["last_message"]["text"]
if message_text.lower() == "a":
if user_id not in my_list:
my_list.append(user_id)
vk.method("messages.send", {"peer_id": id, "message": "a", "random_id": 0})
elif message_text.lower() == "b":
if user_id in my_list:
vk.method("messages.send", {"peer_id": id, "message": "b", "random_id": 0})
my_list.remove(user_id)
else:
...
import random
count = 0
print("-------Guess my number-------")
print("You need to guess the number picked by enigmatic computer!")
print("Number is in range from 1 to 10")
user_number = None
magic_number = random.randint(1, 10)
while user_number != magic_number:
magic_number = random.randint(1, 10)
user_number = int( input("Your number: ") )
count += 1
if magic_number > user_number:
print("The magic number is greater than yours!")
elif magic_number < user_number:
print("The magic number is less than yours!")
print("You Win! You guessed it on the", count, "try")
print("Want to play again?")
answer = input()
if answer == "no":
print("Okay, see you later")
break
def task_3(m):
m_lines = m.split("\n")[:-4]
m = ""
for line in m_lines:
m += f"{line}\n"
return m[:-1]
# Сигналы зажатия кнопки.
self.button.pressed.connect(self.pressed_)
# Сигналы отпускания кнопки.
self.button.released.connect(self.release_)
count = 0
orders = data['data']['orders']
for item_order in orders:
if 'order_crew_group_id' in item_order:
count += 1
print(count)
count = 0
orders = data['data']['orders']
for item_order in orders:
if 'order_crew_group_id' in item_order:
if item_order['order_crew_group_id'] == 2:
count += 1
print(count)
AttributeError: 'str' object has no attribute 'act'
import os
# Импортируем glob для нахождения файлов в папке.
from glob import glob
# Папка, в которой находятся файлы.
folder = 'file'
# Директория.
filedir_ = __file__
filename_ = os.path.basename(filedir_)
basedir_ = filedir_.replace(filename_, '')
# Список всех файлов с расширением .py в папке folder.
files = glob(fr'{basedir_}{folder}\*.py')
# Своеобразное импортирование из файлов.
for file in files:
code_in_file = open(file, 'r', encoding='utf8').read()
exec(code_in_file, globals())
# Выводим переменные.
print(var_1)
print(var_2)
print(var_3)
list_ = ['photo-0_0', 'photo-1_1']
vk_session.method('messages.send', {... 'attachment': list_})