from itertools import product
zav = {'a': ['а', '@', 'A'], 'b': ['b', 'б'], 'ч': ['4'], 'и': ['u'], 'к': ['k']}
bad_word = "пончик"
# список всех возможных вариантов подстановки
bad_words = [''.join(word) for word in product(*[[x]+zav.get(x, []) for x in bad_word])]
print(bad_words)
# ['пончик', 'пончиk', 'пончuк', 'пончuk', 'пон4ик', 'пон4иk', 'пон4uк', 'пон4uk']
for A in range(1000, -101, -1):
f = 0
for x in range(0, 101):
for y in range(0, 101):
if ((2*x+y>A) or (y>20) or (x>30))==False:
f=1
break
if f == 1:
break
if f == 0:
print(A)
break
from functools import partial
def write(pulse, pressure, datetime):
with open("pulse.txt", "w") as file:
file.write(pulse.get())
butt = Button(root, text="Записать", command=partial(write, pulse, pressure, datetime))
print("Температура норм, одевай что угодно." ())
def delete():
list.remove(max(list))
list.removе(min(list))
print(*list, sep=", ")
def get_middle(arr):
return sorted(arr)[1]
vk_api.lоngpoll.VkLongPoll
vk_api.bot_longpoll.VkBotLongPoll
....
akkreditation.append(akkr)
all_data.append(akkreditation)
print(akkreditation)
# после окончания всех циклов и будет вложенный список
print(all_data)
d1 = {'Апельсин': 1,
'Яблоко': 2,
'Банан': 3
}
d2 = {'Апельсин': 2,
'Яблоко': 2,
'Инжир': 1
}
print(d1.keys())
# общие ключи
print(d1.keys()&d2.keys())
cursor.execute("SELECT price FROM statistic WHERE `date` = %s AND `time` = %s", (date, f"{deltime_1.hour}:{deltime_1.minute}"))
def file_write(key, val):
try:
data = json.load(open(storage_path))
except:
data = {}
if key in data:
data[key].append(val)
else:
data[key] = [val]
with open(storage_path, "w") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
def file_read(key):
with open(storage_path, "r"):
data = json.load(open(storage_path))
print(data.get(key, 'Пусто'))
if a or f < 0
if (bool(a) == True) or (bool(f < 0) == True)
import pandas as pd
data = [('18835', [{'ID': '2903', 'OWNER_ID': '18835', 'OWNER_TYPE': 'D', 'PRODUCT_ID': 3839, 'PRODUCT_NAME': 'Установка ПП 1С', 'ORIGINAL_PRODUCT_NAME': 'Установка ПП 1С', 'PRODUCT_DESCRIPTION': 'Установка ПП 1С', 'PRICE': 1300, 'PRICE_EXCLUSIVE': 1300, 'PRICE_NETTO': 1300, 'PRICE_BRUTTO': 1300, 'PRICE_ACCOUNT': '1300.00', 'QUANTITY': 1, 'DISCOUNT_TYPE_ID': 2, 'DISCOUNT_RATE': 0, 'DISCOUNT_SUM': 0, 'TAX_RATE': 0, 'TAX_INCLUDED': 'N', 'CUSTOMIZED': 'Y', 'MEASURE_CODE': 356, 'MEASURE_NAME': 'ч', 'SORT': 10}]), ('5199', []), ('23291', [{'ID': '7407', 'OWNER_ID': '23291', 'OWNER_TYPE': 'D', 'PRODUCT_ID': 6483, 'PRODUCT_NAME': 'Установка и обновление ПП', 'ORIGINAL_PRODUCT_NAME': 'Установка и обновление ПП', 'PRODUCT_DESCRIPTION': 'Установка и обновление ПП', 'PRICE': 1300, 'PRICE_EXCLUSIVE': 1300, 'PRICE_NETTO': 1300, 'PRICE_BRUTTO': 1300, 'PRICE_ACCOUNT': '1300.00', 'QUANTITY': 0.5, 'DISCOUNT_TYPE_ID': 2, 'DISCOUNT_RATE': 0, 'DISCOUNT_SUM': 0, 'TAX_RATE': 0, 'TAX_INCLUDED': 'N', 'CUSTOMIZED': 'Y', 'MEASURE_CODE': 356, 'MEASURE_NAME': 'ч', 'SORT': 10}]), ('609', [])]
# формируем список словарей со значениями по колонкам
df_data = [row[1][0] for row in data if row[1]]
prod = pd.DataFrame(df_data)
with pd.ExcelWriter('B24.xlsx',
mode='w') as writer:
prod.to_excel(writer, sheet_name='Товары')