from string import hexdigits
def is_valid_address(address: str) -> bool:
return len(address) == 66 and all(c in hexdigits[:-6] for c in address)
y = '%s-%s-%d.node.eu.consul' % (parts[0], parts[1], str(parts[2]) + 6)
y = '%s-%s-%d.node.eu.consul' % (parts[0], parts[1], int(parts[2].split('.')[0]) + 6)
number = int(parts[2].split('.')[0])
y = '%s-%s-%d.node.eu.consul' % (parts[0], parts[1], number + 6)
number = int(parts[2].split('.')[0])
y = '{}-{}-{}.node.eu.consul'.format(parts[0], parts[1], number + 6)
...
answer = message.text
data = await state.get_data()
name = data.get('hi')
number = data.get('number')
priyom = data.get('priyom')
sdacha = data.get('sdacha')
...
list = ['a', 'b', 'c', 'd', 'e']
list1 = list[:2] # ['a', 'b']
list2 = list[2:] # ['c', 'd', 'e']
from collections import Counter
lst = ['a', 'b', 'c', 'd', 'e']
lst1 = ['a', 'c']
lst2 = list((Counter(list) - Counter(list1)).elements()) # ['b', 'd', 'e']
from io import BytesIO
from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=FZ1mj9IaczQ')
audio_stream = yt.streams.filter(only_audio=True)[0]
buffer = BytesIO()
audio_stream.stream_to_buffer(buffer)
buffer.seek(0)
from pyrogram import Client
from pyrogram.raw.functions.contacts import ResolveUsername
BOT_TOKEN = "<токен бота>"
pyrogram_client = Client(
"bot",
api_id=6,
api_hash="eb06d4abfb49dc3eeb1aeb98ae0f581e",
bot_token=BOT_TOKEN,
app_version="7.7.2",
device_model="Lenovo Z6 Lite",
system_version="11 R"
)
def resolve_username_to_user_id(username: str) -> int | None:
with pyrogram_client:
r = pyrogram_client.invoke(ResolveUsername(username=username))
if r.users:
return r.users[0].id
return None
print(resolve_username_to_user_id("Tishka17"))
def resolve_username_to_channel_id(username: str) -> int | None:
with pyrogram_client:
r = pyrogram_client.invoke(ResolveUsername(username=username))
if r.chats:
return r.chats[0].id
return None
>>> help(set)
Python 3.10.5 (main, Aug 1 2022, 07:53:20) [GCC 12.1.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: set?
Init signature: set(self, /, *args, **kwargs)
Docstring:
set() -> new empty set object
set(iterable) -> new set object
Build an unordered collection of unique elements.
Type: type
Subclasses:
In [2]: %pdef set
No definition header found for set
In [3]: %pdoc set
Class docstring:
set() -> new empty set object
set(iterable) -> new set object
Build an unordered collection of unique elements.
Init docstring:
Initialize self. See help(type(self)) for accurate signature.
In [4]: %psource set
No source found for set