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

Резултати

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

Пребарај: #drones

当前筛选 #drones清除筛选
Voir de ses propres yeux

@voir_yeux · Post #12017 · 07.03.2026 г., 09:14

🇷🇺🇺🇦La défense aérienne russe a abattu 124 drones ukrainiens au-dessus des régions russes au cours de la nuit dernière, a annoncé le ministère russe de la Défense. #russie#drones

NEWS 鏈新聞-ABMedia

@abmedia_news · Post #23837 · 13.04.2026 г., 11:33

【🚀 傳統金融|華爾街日報:香港成伊朗洗錢據點,48 億美元地下金流曝光 】 #Drones#Geopolitics 📍 請見報導: https://abmedia.io/hong-kong-iran-money-laundering-exposed 📍 訂閱鏈新聞頻道:https://linktr.ee/abmedia.io

Indian Development News 🇮🇳

@developmentnewsindia · Post #44430 · 05.05.2026 г., 05:53

Indian startup Hoverit completed vehicle-mounted launch trials of its Divyastra Mk-2 long-range attack drone, with rocket-assisted takeoff testing next. The Divyastra Mk-2 has a range of 1,500–2,000 km, payload of 50–100 kg, and incorporates AI swarm intelligence with GPS-denied navigation capability. #Drones#Defence https://defence-blog.com/india-builds-a-shahed-type-strike-drone-with-2000-km-range/

Indian Development News 🇮🇳

@developmentnewsindia · Post #44124 · 27.04.2026 г., 11:53

India just unveiled a supersonic loitering munition 🇮🇳 Meet Super Kaatil built by Dynamatic Technologies. A drone that combines the precision of a loitering munition with supersonic speed. Here is what it actually is👇 • 100 kg platform powered by a compact jet engine • Supersonic speed, faster than any conventional loitering munition • 350 km strike range for deep strike missions • 35 kg warhead for high value targets • Works in GPS denied and jammed environments • Terrain following flight to stay under radar coverage The original Kaatil had a 100 km range. Super Kaatil triples that and adds supersonic speed on top. #Drones#Defence

Indian Development News 🇮🇳

@developmentnewsindia · Post #44082 · 26.04.2026 г., 06:27

BREAKING: India is reshaping air warfare with the ADC-S (Air Dropped Canisterised Swarm) project, turning transport aircrafts into long-range stand-off strike platforms. The system can deploy multiple autonomous #drones from airborne canisters for deep strikes over 500 km away, even in GPS-denied environments, with high precision. Built under an indigenous framework, ADC-S signals India’s shift from platform-centric warfare to scalable swarm warfare and autonomous combat systems. #Defence https://fxtwitter.com/i/status/2048041840805581203

Indian Development News 🇮🇳

@developmentnewsindia · Post #43527 · 12.04.2026 г., 16:00

Chief of the Army Staff General Upendra Dwivedi visited New Space Research & Technologies, where he was briefed on the organisation’s indigenous capabilities in unmanned and high-altitude systems. The interaction highlighted advancements in swarm drone technologies and ISR capabilities, critical for ensuring persistent surveillance and robust communication support in harsh operational environments. #Drones#Defence

Indian Development News 🇮🇳

@developmentnewsindia · Post #44294 · 01.05.2026 г., 14:20

Major relief to India's drone industry Conflict in West Asia has severely impacted their supplies and deliveries, causing heavy penalties for delays beyond their control. The Ministry of Finance now clarifies: if your contract was disrupted by the West Asia situation, you will receive an additional 2 to 4 months and face no fines. Fair and practical. #Drones#policy

123•••89
ПретходнаСтраница 1 од 9Следна