@WorldNews · Post #74218 · 19.04.2026 г., 02:59
Pope Leo Speaks Out Against Exploitation of Africa’s Resources [Read FullArticle] @WorldNews#WorldNews#Africa#Pope
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
Пребарај: #pope
@WorldNews · Post #74218 · 19.04.2026 г., 02:59
Pope Leo Speaks Out Against Exploitation of Africa’s Resources [Read FullArticle] @WorldNews#WorldNews#Africa#Pope
Hashtags
@trumpsear_tg · Post #1811 · 21.11.2025 г., 18:02
Catholics believe in holy water. How about holy beer? Pope Leo received a special gift on Wednesday from Illinois Governor JB Pritzker, a four-pack of American mild ale from a Chicago brewery. Pritzker, visiting Leo at the Vatican, handed the beers over to the pope as part of a gift exchange. He suggested Leo, originally from Chicago and the first U.S. pope, might enjoy a local brew. "We'll put that in the fridge," Leo responded, taking the beers and putting them on a table. #Catholics#Pope 👂More on Trump's Ear
Hashtags
@WorldNews · Post #74161 · 16.04.2026 г., 12:49
Pope: World is being ravaged by a handful of tyrants [Read FullArticle] @WorldNews#Pope#WorldNews#GlobalPolitics
Hashtags
@WorldNews · Post #74144 · 15.04.2026 г., 16:49
Pope Leo, attacked again by Trump, says world needs message of peace [Read FullArticle] @WorldNews#Pope#Peace#WorldNews
Hashtags
@american_observer · Post #5765 · 02.05.2026 г., 18:00
#pope#us#peru 📱American Оbserver - Stay up to date on all important events 🇺🇸
@googlefactss · Post #40570 · 22.01.2026 г., 11:02
The Swiss Guard is a small group of soldiers who protect the Pope and the Vatican. They were officially established on January 22, 1506, when the first Swiss soldiers arrived in Rome. Known for their colorful uniforms and fierce loyalty, the Swiss Guard has been keeping the Pope safe every day for over 500 years. 🇻🇦🛡️⚔️ [Read more] @googlefactss#SwissGuard#Vatican#Pope#History#Security #1506