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

Резултати

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

Пребарај: #belgium

当前筛选 #belgium清除筛选
POPULAR FRONT

@popularxfront · Post #5351 · 09.03.2026 г., 20:13

🇧🇪#Belgium: An explosion occurred earlier today outside a synagogue in the city of Liège, causing damage to the building and nearby windows. No injuries were reported. Authorities established a security perimeter around the site, and Belgium’s federal prosecutor’s office, which handles terrorism and organized crime cases, has taken over the investigation. Officials have not yet released further details about the cause of the explosion, though local authorities described the incident as an "antisemitic act". (via BBC)

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #621 · 14.12.2023 г., 14:09

Belgium, Bruges🇧🇪 Christmas Magic in Bruges! 🎄💫 In December Bruges comes alive with twinkling lights, joyful spirits and Christmas markets, of course. 🫶 Wandering through the cobbled streets adorned with festive stalls, where the aroma of mulled wine dances in the crisp winter air is something else. ❤️ ⭐️ Who would you visit Bruges with? #Belgium @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #523 · 24.11.2023 г., 14:03

Belgium, City of Bruges🇧🇪 Bruges is a small Belgian city and the capital of West Flanders. Once the unofficial economic capital of Northwestern Europe, it has now become an important tourist center of the continent. 🏰🏙 Well-preserved medieval quarters in the historic center, crisscrossed by canals, have earned Bruges the rightful claim to be called the "Venice of the North." #Belgium @voyage

Hashtags

Tibicen

@world_music_geek · Post #29 · 20.09.2020 г., 09:20

Rum — Rum (Philips, 1972) #traditional#Belgium Первый альбом бельгийской фолк-группы Rum, исполнявшей традиционную и академическую музыку, среди которой — сочинения юриста и композитора Флоримона Ван Дуйса (Florimond Van Duyse), собиравшего голландские, фламандские и валлонские народные песни и опубликовавшего их в нескольких сборниках, которыми, видимо, и воспользовались Rum. Telegram

POPULAR FRONT

@popularxfront · Post #5910 · 16.04.2026 г., 13:49

🇧🇪#Belgium - 🇬🇧#UK / 🇮🇱#Israel: Belgian authorities seized two UK-origin shipments of military components bound for Israel after they arrived at Liège Airport on March 24th, where they had been scheduled for onward transport to Tel Aviv two days later. The cargo reportedly included fire-control systems and spare parts for military aircraft. A criminal case was opened as a result of this discovery. Walloon Minister-President Adrien Dolimont said this was not the first such case uncovered at Liège, adding that it is often difficult to identify military cargo. He stated that, in this case, the law had clearly not been respected, stressing that no transit licence had been requested, and regardless of request, such a transfer would have been refused under Belgium’s current policy. (via declassifiedUK)

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40021 · 06.11.2025 г., 03:03

Happy Saxophone Day! 🎷🎵🎶 The saxophone was invented by Belgian Adolphe Sax in the early 1840s — his birthday, Nov 6, is celebrated as National Saxophone Day. Feel free to post saxophone music in the comments. [read more here] @googlefactss#funfact#saxfact#history#Belgium

Tibicen

@world_music_geek · Post #31 · 20.09.2020 г., 09:29

't Kliekske — Instrumentaal (CBS, 1978) #medieval#traditional#Belgium 't Kliekske — бельгийская группа, исполнявшая старинную традиционную фламандскую музыку. Они собрали бесчисленное количество народных песен, мелодий, танцев и инструментов. Один из участников коллектива, Герман Девит, занимался реконструкцией старинных инструментов. В 1995 году Герману было присвоена степень доктора за его исследования и исполнение народной музыки. Группа также являлась инициатором ежегодных курсов народной музыки сначала в Гальмаардене, а затем в Пайоттенланде. На этом альбоме собраны записи произведений из рукописи, обнаруженной Гисленом Потвлиге (Ghislain Potvlieghe) во фламандской деревне Виан. Telegram

POPULAR FRONT

@popularxfront · Post #4941 · 09.02.2026 г., 08:04

🇱🇻#Latvia - 🇪🇪#Estonia - 🇧🇪#Belgium: Latvia, Estonia, and Belgium have become the first NATO countries to begin deploying the "Blaze" fully autonomous interceptor drone system along their borders amid increasing reports of unauthorized drone incursions in their airspace. Developed and manufactured in Latvia by Origin Robotics, the Blaze is an autonomous counter-drone interceptor designed to detect, track, and destroy hostile drones and other fast moving aerial targets using radar, AI powered computer vision, and a high explosive fragmentation warhead. (via Origin Robotics)

POPULAR FRONT

@popularxfront · Post #6061 · 26.04.2026 г., 20:26

🇫🇷#France - 🇮🇹#Italy / 🇬🇷#Greece / 🇪🇸#Spain / 🇧🇪#Belgium: Troops from several countries (Greece, Italy, Spain, and Belgium) have conducted river-crossing exercises in France’s Aube region alongside French troops. The exercises are part of the broader Orion 2026 military training program. (via AFP)

Tibicen

@world_music_geek · Post #906 · 28.02.2025 г., 09:06

Lukas De Clerck — The Telescopic Aulos of Atlas (Ideologic Organ, 2024) #aulos#drone#ambient#Belgium Лукас Де Клерк в своём дебютном сольном альбоме исследует возможности телескопического авлоса — современной интерпретации древнегреческого инструмента, исчезнувшего более тысячелетия назад. Его работа находится на пересечении экспериментальной музыки, таких направлений как дрон и постминимализм, и современных археомузыкологических исследований. 🔗AppleMusic | Spotify | Deezer | SoundCloud | Bandcamp

ПретходнаСтраница 1 од 3Следна