TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #146 · 16 сеп.

Функция sub в regex может принимать функцию в качестве аргумента repl. 📄 Из документации: If repl is a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. То есть для каждого совпадения будет вызвана функция для вычисления замены вместо замены на одну и ту же строку для всех совпадений. Иными словами, для замены разных совпадений на разные строки не потребуется запускать re.sub() много раз для каждой строки замены. Достаточно определить функцию, которая вернёт строку для каждого из совпадений. Описание слишком запутанное🤔, давайте лучше рассмотрим на простом примере: Создаем карту замены. То есть какие строки на какие требуется менять. remap = { 'раз': '1', 'два': '2', 'три': '3', 'четыре': '4', 'пять': '5', } Пишем функцию поиска строки для замены. Единственным аргументом будет объект re.Match. Используя данные этого объекта мы вычисляем замену on-the-fly! def get_str(match: re.Match): word = match.group(1) return remap.get(word.lower()) or word Пример текста. text = '''Раз Два Три Четыре Пять Вместе будем мы считать Пять Четыре Три Два Раз Мы считать научим вас ''' Теперь запускаем re.sub и вместо строки замены (repl) подаём имя функции. (Данный паттерн ищет отдельные слова в тексте) >>> print(re.sub(r'(\w+)', get_str, text)) 1 2 3 4 5 Вместе будем мы считать 5 4 3 2 1 Мы считать научим вас Думаю, достаточно наглядно 🤓 #libs#regex

Hashtags

Резултати

Пронајдени 7 слични објави

Пребарај: #send

当前筛选 #send清除筛选
Libreware

@libreware · Post #1003 · 27.10.2021 г., 01:09

Croc Easily and securely send things from one computer to another Features - allows any two computers to transfer data (using a relay) - provides end-to-end encryption (using PAKE) - enables easy cross-platform transfers (Windows, Linux, Mac, Android) - allows multiple file transfers - local server or port-forwarding not needed - ipv6-first with ipv4 fallback https://github.com/schollz/croc https://f-droid.org/en/packages/com.github.howeyc.crocgui/ 📡@NoGoolag📡@Libreware #croc#transfer#send#share

Libreware

@libreware · Post #1550 · 17.02.2026 г., 04:42

Alt-sendme — send files and folders to anywhere in the world without storing them in the cloud — any size, any format, without accounts and restrictions. A free file transfer tool with open source code, using the capabilities of an advanced peer-to-peer network, allowing you to transfer files directly without storing them on cloud servers. @github #P2P#FileTransfer#share#send#transfer

BotsGram®

@botsgram_cu · Post #3988 · 07.06.2021 г., 16:55

@etlgr_bot Qué puede hacer este bot? Obtén una dirección de correo para cualquier Chat de Telegram (grupo o usuario). Enviar y recibir correos. Idioma: Inglés (visto en @BotsGram_cu) #send, #mail, #email, #address, #welcome

BotsGram®

@botsgram_cu · Post #3379 · 11.01.2021 г., 13:10

@Shekelbot Qué puede hacer este bot? ShekelBot le ayudará a contar su dinero. Úselo, cuando le das dinero a alguien, o comparte compras. Idioma: Inglés (visto en @BotsGram_cu) #money, #track, #send, #receive, #friends, #debt

BotsGram®

@botsgram_cu · Post #3357 · 03.01.2021 г., 16:25

@posttobot Qué puede hacer este bot? Este bot le ayuda a enviar un mensaje a alguien en Telegram Messenger sin usar Telegram a través de este Bot conectado con una aplicación web. Idioma: Inglés, Ruso (visto en @BotsGram_cu) #web, #pc, #remote, #telegram, #message, #text, #send, #post, #bot, #dictionary

BotsGram®

@botsgram_cu · Post #3283 · 13.12.2020 г., 03:10

@DebtsTrackerBot Qué puede hacer este bot? Este bot realiza un seguimiento de sus deudas y envía recordatorios a usted y a los deudores por Telegram y SMS. Idioma: Español, Inglés, Ruso, Italiano (visto en @BotsGram_cu) #friend, #money, #track, #debt, #send, #receive, #issue, #website, #request