class MyClient(discord.Client):
...
async def on_voice_state_update(self, member, before, after):
if after.channel and after.channel!=before.channel:
print(f"Пользователь {member.name} зашол на {after.channel.name}")
if before.channel and after.channel!=before.channel:
print(f"Пользователь {member.name} вышел с {before.channel.name}") pip install <название пакета>pip install --find-links C:\TEMP <название пакета>from random import random
N = 100
#Создадим список компаний из 100 компаний цена от 2000 до 3000, качество от 150 до 200 единиц
orders = [{"name":"Company {0:03d}".format(x),"price":2000+int(random()*1000),"quality":150+int(random()*50)} for x in range(N)]
#отсортируем по отноцению цена/качество наиболее выгодные будут в внчале списка
orders = sorted(orders,key=lambda x: x["price"]/x["quality"])
print("Top 5:"+",\t".join(orders[0].keys()))#заголовок
#выведем 5 первых по выгоде
print("\n".join([",\t".join(map(str,x.values())) for x in orders[:5]])) self.answer1 = Button(
frame, text="2", command=lambda: self.check(2)
)def zzip(ID_Master,ID_Masterok):
result = {}
for i in ID_Masterok:
if ID_Master[i] in result:
if isinstance(result[ID_Master[i]],list):
result[ID_Master[i]].append(i)
else:
result[ID_Master[i]] = [result[ID_Master[i]],i]
else:
result[ID_Master[i]] = i
return result >>> from urllib.parse import urlparse
>>> u = urlparse("postgres://admin:oocooSh7@postgres.host:5432/my_db")
>>> u.password
'oocooSh7'
>>> u.username
'admin'
>>> u.hostname
'postgres.host'
>>> u.port
5432
>>> u.path
'/my_db'
>>> us = urlparse("sqlite:///C:/Users/admin/site_db.sqlite3")
>>> us.path
'/C:/Users/admin/site_db.sqlite3'
>>> us.scheme
'sqlite'
>>>import pyqrcode
qr_obj = pyqrcode.create('QR ТЕКСТ')
buffer = BytesIO()
qr_obj.png(buffer, scale=10)
bot.send_photo(chat_id=some_chat_id, photo=buffer.getvalue()) import hmac
import hashlib
from base64 import b64encode
@app.route("/qiwi-notify", methods=['POST'])
def QiwiNotify():
error = 1
req = request.json.get("bill")
qSignature = request.headers.get("X-Api-Signature-SHA256")#предположительно строка в base64
hSignature = b64encode(hmac.new(config["SECRET_QIWI_KEY"],msg="{}|{}|{}|{}|{}".format(\
req["amount"]["currency"],req["amount"]["value"],req["billId"],req["siteId"],req["status"]["value"]\
),digestmod=hashlib.sha256).digest())
#для отладки
print ([qSignature,hSignature])
print (req)
if qSignature == hSignature:
#заносим в базу данные о счете и меняем error если неудачно.
error = 0
return jsonify({"error":error})