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

Резултати

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

Пребарај: #satire

当前筛选 #satire清除筛选
movies & series 🍿

@images · Post #1803 · 15.03.2025 г., 17:55

🍿 'Sicko': Watch Michael Moore's Eye-Opening Documentary for FREE 📆Release: 2007 🎭Genre: #Documentary · #Satire Michael Moore, known for 'Fahrenheit 9/11' and 'Bowling for Columbine', exposes the brutal truth behind the U.S. healthcare system in 'Sicko'. With his bold and provocative style, Moore reveals how insurance companies prioritize profits over people's lives. In the documentary, Moore compares this system to public healthcare models in Canada, the UK, France, and even Cuba — where an inhaler costs just five cents. The film shocks with heartbreaking stories of those abandoned by the system. Love him or hate him, Moore's powerful message makes 'Sicko' a must-see. And now you can watch it for FREE 🎬

Hidden In Plain Sight

@hiddeninplainsight1 · Post #24463 · 29.04.2026 г., 01:37

🇦🇺 PM Albanese assures the Australian public he is tackling the housing crisis making sure things aren’t “too fair” for “too long”…..🤪🤡 [Rupert Degas] #satire#funnynotfunny https://t.me/hiddeninplainsight1

The Innercircle Trader SMC community

@theinnercirclesmccommunity · Post #1376 · 09.02.2026 г., 10:31

Folks, we interupt... I'm sorry, repeat that again? It's still dropping, my word!? Okay Folks, you're advised to take your seats and gather the children. We interrupt your program to inform you with this fast developing story, please calm down and brace yourselves! Bincoin has continued its dramatic spiral down... and I'm just so shocked as all of you, I'm sure. Brace yourself... Bincoin is at 60k, ladies and gentleman please remain calm! The government advises remaining indoors due to roving mobs with pitchforks and torches are afoot. Dim your lights and shelter in place!!! #Satire #ImSuchUhStinker

AES INFO

@aesinfos · Post #2443 · 30.01.2025 г., 11:16

#AESinfo | #Satire🇨🇵 Candace Owens lâche une bombe… ou un pétard mouillé ? #CandaceOwens balance tout AUJOURD'HUI sur… Brizbite Macron pardon sur Jean-Michel Trogneux… ah non plutôt sur Brigitte Macron On s'y perd complètement, mais une chose est sûre : Owens prétend révéler un scandale XXL. Alors, pétard mouillé ou vraie bombe médiatique ? La France retient son souffle. Pendant ce temps, Emmanuel Macron : en sueur ou simplement amusé par le spectacle ? That is the question !

AES INFO

@aesinfos · Post #1953 · 29.11.2024 г., 11:34

#AESinfo | #Nigeria🇳🇬🤝🏾🇨🇵#France #Satire : Macron face au casse-tête nigérian : des calebasses à l'Élysée, mais où est l'argent ? Après l'affaire des djembés remplis de billets verts offerts par Blaise Compaoré à Jacques Chirac, voilà que la tradition des cadeaux exotiques entre l'Afrique et la France se poursuit. Lors de la récente visite officielle du président nigérian au palais de l'Élysée, son épouse, Oluremi Tinubu, a offert à Brigitte Macron de splendides calebasses artisanales. Si le geste est certes élégant, on ne peut s'empêcher de se demander : quel trésor cachent ces objets d'art ? Des diamants ? De l'or ? Ou simplement de l'eguci sauce ? Le mystère plane sur la valeur réelle de ces présents. Retrouvez l’article complet sur Twitter X @AESinfos Facebook https://www.facebook.com/share/19iRSjDVPn/?mibextid=LQQJ4d

des Geyers schwarzer Haufen

@FlorianGeyer2024 · Post #3074 · 09.12.2025 г., 15:39

👀🎶🙂🇩🇪🏴‍☠️ = 🍌🐀🥙 ............. 📺 Mehr meta-autistischer Wahnsinn rund um die uhr auf https://blobtv.de .................... Die neue Willy HIER: https://snicklink.de Quelle Link: 👀 Teilen kann zum Aufwachen beitragen! ✨🆕🌐Hauptkanal ✨▶️🌐 Videokanal ✨▶️🙂Funnykanal #Deutschland#Rattendöner#Satire#SnickLink

des Geyers schwarzer Haufen

@FlorianGeyer2024 · Post #2918 · 15.11.2025 г., 07:45

👀🤡⚰️⚱️🪦🇩🇪🏴‍☠️Neue Version. Alte Message. 🕊 .......................... 📺 MEHR meta-autistische Schwurbelcomedy rund um die Uhr auf https://blobtv.de .................... Die neue Willy HIER: https://snicklink.de Quelle Link: 👀 Teilen kann zum Aufwachen beitragen! ✨🆕🌐Hauptkanal ✨▶️🌐 Videokanal ✨▶️🙂Funnykanal #deutschland#cdu#merz#Pistorius#Spahn#Lügner#Hochverrat#Wahlfälschung#Korruption#Kanonenfutter#Wehrpflicht#Wehrdienst#SnickLink#Satire#BlobTV