...
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)
>>> 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
...
soup = requests.get(
url='https://web.telegram.org/k/#@gayshiit',
headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36'}
).text
...
recursive-include package_name/dir1 *
recursive-include package_name/dir2 *
from setuptools import setup, find_packages
...
setup(
...
include_package_data=True
)
import asyncio
from vkbottle import API
async def main():
api = API("vk1.a.mlzFZ7N-xNVWFn505pvSCKRsVbqdAua99kiQ149ovBUvPQIDVoJh6s3CoOsAZk7H7gfWdN0bS4x4bQOu_9EvQU3TQvi8TSmJ2U0dNmmTUvTruPgPm6kw8Srzb8qMbVzNUy0TfdRfalrx-_la2XqfEX1")
await api.wall.create_comment(owner_id=-4854, post_id=277, message="ком")
asyncio.run(main())
s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit 76 111 114 101 109 32 105 112 115 117 109"
repl_s = "".join("0" if i.isdigit() else "*" if i.isalpha() else i for i in s)
import string
table = str.maketrans({i: "*" for i in string.ascii_letters} | {i: "0" for i in string.digits})
repl_s = s.translate(table)
import re
repl_s = re.sub(r'[a-zA-Zа-яА-ЯёЁ]', '*', re.sub(r'\d', '0', s))
"***** ***** ***** *** ****, *********** ********** **** 00 000 000 000 000 00 000 000 000 000 000"
cols = ['id', 'name', 'pass']
old_list = [[1, 'вася', '123'],[2,'mike','321'],[3,'john','password']]
g_dict = []
for item in old_list:
g_dict.append(dict(zip(cols, item)))
cols = ['id', 'name', 'pass']
old_list = [[1, 'вася', '123'],[2,'mike','321'],[3,'john','password']]
g_dict = [dict(zip(cols, item)) for item in old_list]
import textwrap
text = "В центре города большого, где травинки не растёт, жил поэт, волшебник слова, - вдохновенный рифмоплёт. Рифмовал он что попало, просто выбился из сил, и в деревню на поправку, где коровы щиплют травку, отдыхать отправлен был."
shortened_text = textwrap.shorten(text, width=100, placeholder="…") # "В центре города большого, где травинки не растёт, жил поэт, волшебник слова, - вдохновенный…"
<div class="kris-news-box">…</div>
post = soup.find("div", class_="kris-news-box")
import sys
print(sys.getrecursionlimit()) # Получить текущий лимит рекурсии
sys.setrecursionlimit(1500) # Установить лимит рекурсии в 1500
LIMIT = 1500
def test(..., calls=0):
...
if calls >= LIMIT:
return
return test(..., calls=calls + 1)
from pyrogram import Client
from pyrogram import types, filters
CHANNEL_ID = -11012345678
app = Client(
"my_account",
api_id=12345,
api_hash="0123456789abcdef0123456789abcdef"
)
@app.on_message(filters=filters.channel)
def my_handler(client: Client, message: types.Message):
if message.chat.id != CHANNEL_ID:
return
print("Получено новое сообщение с ID", message.message_id)
# Как-то обработать сообщение с канала, например, напечатать его текст
print("Текст:", message.text)
app.run()
@app.on_message(filters=filters.channel & ~filters.edited)