@blumgap · Post #3156 · 16.07.2025 г., 16:30
❓️Quote of the Day :16 Jul 🙋♂ Answer :Booker T. Washington 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
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
Пребарај: #hrum
@blumgap · Post #3156 · 16.07.2025 г., 16:30
❓️Quote of the Day :16 Jul 🙋♂ Answer :Booker T. Washington 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #3123 · 15.07.2025 г., 16:22
❓️Quote of the Day :15 Jul 🙋♂ Answer :Buddha 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #3099 · 14.07.2025 г., 16:20
❓️Quote of the Day :14 Jul 🙋♂ Answer :Roy T. Bennett 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #3078 · 13.07.2025 г., 16:36
❓️Quote of the Day :13 Jul 🙋♂ Answer :Pablo Picasso 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #3058 · 12.07.2025 г., 16:58
❓️Quote of the Day :12 Jul 🙋♂ Answer :Mother Teresa 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #3037 · 11.07.2025 г., 16:33
❓️Quote of the Day :11 Jul 🙋♂ Answer :Henry Ford 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #3021 · 10.07.2025 г., 16:42
❓️Quote of the Day :10 Jul 🙋♂ Answer :Maya Angelou 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #3004 · 09.07.2025 г., 18:01
❓Quote of the Day :09 Jul 🙋♂️ Answer :Sam Levenson 🔗 Link :Hrum #hrum
Hashtags
@airdrop_presents · Post #2995 · 01.09.2024 г., 13:56
IF U MISS ARKM DON'T MISS $HRUM & $CAT #HRUM....If u're able to be on top 100 on this Airdrop consider farming easy £25k....we are early on this just decided to share early to u guys enjoy the journey Must perform all task I'm to be eligible Use the below links👇👇 HRUM (Task 1) Backed by ARKM team that was listed on binanace http://t.me/hrummebot/game?startapp=ref1184191157 $CAT (Task 2) http://t.me/catsgang_bot/join?startapp=4gXIT6LZx_lUccfDA9OD9 ⚠ Complete all task to be eligible
Hashtags
@blumgap · Post #2983 · 08.07.2025 г., 16:47
❓️Quote of the Day :08 Jul 🙋♂ Answer :Zig Ziglar 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #2968 · 07.07.2025 г., 16:21
❓️Quote of the Day :07 Jul 🙋♂ Answer :Colin R. Davis 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags
@blumgap · Post #2948 · 06.07.2025 г., 16:46
❓️Quote of the Day :06 Jul 🙋♂ Answer :Mark Twain 🔗 Link :Hrum #hrum ❤️ If you appreciate our work, tap a like or heart to support — we’ll keep bringing top passive income projects!
Hashtags