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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #65 · 8 апр.

Небольшой трик с регулярными выражениями который редко вижу в чужом коде. Допустим, вам нужно распарсить простой текст и вытащить оттуда пары имя+телефон. Вернуть всё это надо в виде списка словарей. Возьмем очень простой пример текста. >>> text = ''' >>> Alex:8999123456 >>> Mike:+799987654 >>> Oleg:+344456789 >>> ''' Соответственно, для выделения нужных элементов будем использовать группы. Получится такой паттерн: (\w+):([\d+]+) Как мы будем формировать словарь из найденных групп? >>> import re >>> results = [] >>> for match in re.finditer(r"(\w+):([\d+]+)", text): >>> results.append({ >>> "name": match.group(1), >>> "phone": match.group(2) >>> }) >>> print(results) [{'name': 'Alex', 'phone': '8999123456'}, ...] Можно немного сократить запись используя zip >>> results = [] >>> for match in re.finditer(r"(\w+):([\d+]+)", text): >>> results.append(dict(zip(['name', 'phone'], match.groups()))) Но есть способ лучше! Это именованные группы в regex. Можно в паттерне указать имя группы и результат сразу забрать в виде словаря. >>> for match in re.finditer(r"(?P<name>\w+):(?P<phone>[\d+]+)", text): >>> results.append(match.groupdict()) То есть всё что я сделал, это добавил в начале группы (внутри сбокочек) такую запись: (?P<group-name>...) Теперь найденная группа имеет имя и можно обратиться к ней как к элементу списка >>> name = match['name'] Либо забрать сразу весь словарь методом groupdict() >>> match.groupdict() #tricks#regex

Резултати

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

Пребарај: #chriswojcik

当前筛选 #chriswojcik清除筛选
bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1952 · 30.04.2026 г., 23:43

🐈‍⬛NEW RELEASE 🐈‍⬛ 🐈‍⬛Woj Lock 2.0 - Completing The Leg Lock Game by Chris Wojcik 🐈‍⬛ 🐈‍⬛Chris Wojcik isn’t just a leg locker—he’s one of the most innovative finishers in modern grappling, known for catching high-level opponents with his signature “Woj Lock” system. 🐈‍⬛From foundational concepts to advanced 50/50 systems, cross ashi, inside ashi, and beyond—Wojcik shows you how to connect entries, control, and finishing mechanics into one seamless chain. $79 🐈‍⬛$9.99 🐈‍⬛ ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱📱 💰Submeta FOR FREE 👑MasterClass ✈️@bjjfanaticsinstructionals #ChrisWojcik#Submissions#NoGi#ADCC 🐈‍⬛Buy 🐈‍⬛

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1825 · 01.06.2025 г., 21:36

🔥NEW RELEASE🔥 😁Don't Get Passed By Chris Wojcik😁 ➡️Unlock the secrets to unstoppable guard retention and dynamic submission attacks with Don’t Get Passed by Chris Wojcik — the definitive no-gi open guard instructional. ➡️Whether you’re a beginner struggling to keep your guard or an advanced grappler looking to sharpen your game, Chris breaks down the essential principles and techniques that will keep your opponent stuck and scrambling. ➡️Dive deep into a strategic system focused on maintaining control, creating constant dilemmas for your opponent, and flowing seamlessly from guard retention to submission setups. $79😍$9.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #ChrisWojcik#Guard#NoGi#GuardRetention 💁‍♀️Buy 💁‍♀️