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

Резултати

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

Пребарај: #timeline

当前筛选 #timeline清除筛选
Lsposed Modules Updates Tracker

@lsposed_Modules_Updates_Trackers · Post #6828 · 28.04.2026 г., 02:02

#Re#Timeline 模块:nep.timeline.re_telegram 简介:Re Telegram 版本:170-Akiyama 更新时间:2024/12/09 15:29:52 更新日志: Now you can delete your messages normally without having to delete them multiple times @lsposed_Modules_Updates_Trackers | @lsposed_Geeks_Bot

Hashtags

Graph Messenger

@graphmessenger · Post #446 · 22.06.2024 г., 12:58

📄Timeline, a place where you can see all the messages from all subscribed channels. ❤️Redesigned In version 11.10.0 on June 20, 2024. 🗓Was added in version 5.0 on August 19, 2016. #features#message#timeline#feed #graph_messenger#telegram @GraphMessenger @GraphMessengerTips

GitHub Trends

@githubtrending · Post #15208 · 09.10.2025 г., 14:00

#go#archival#data_archiving#data_import#family_history#self_hosted#timeline Timelinize helps you organize your personal data from different sources like photos, messages, and social media into a single timeline on your computer. This keeps your data private and under your control, unlike cloud services. You can import data from many places, view it on a map, and see conversations across different platforms. It's like having a personal journal that you can add to and keep forever, without relying on companies to store it for you. This way, you can keep your memories safe and easily look back at them whenever you want. https://github.com/timelinize/timelinize

✨Lioness⚜️Rising✨🪽♾️

@lionessrises · Post #113061 · 06.05.2026 г., 18:15

After this reset, you will begin the New Earth timeline with new belief systems will guide you. But that is in the future. For today, create boundaries with both the past and the future so you can simply be in this here and now moment. The past no longer defines you. The future is what you decide upon. Yah bless 🌹 Love Carolyn ✨ Get your FREE Quantum Energy Balancing & Tune-up https://www.144godcode.com/freebie #timeline#newearth#reset#rebirth#therealyou #144000 #144GODCODE#APTTMH