@internationalgeographic · Post #5453 · 26.02.2025 г., 00:17
#Switzerland🇨🇭 The resort of the Burgenste on Lake Lucerne is an impressive landscape on a mountain range at an altitude of 500 meters above Lake Lucerne.
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
Пребарај: #switzerland
@internationalgeographic · Post #5453 · 26.02.2025 г., 00:17
#Switzerland🇨🇭 The resort of the Burgenste on Lake Lucerne is an impressive landscape on a mountain range at an altitude of 500 meters above Lake Lucerne.
Hashtags
@artematizando · Post #4871 · 16.09.2025 г., 07:41
San Giovanni Battista Church, by architect Mario Botta, Mogno, #Switzerland (Photos: Stefano Perego)
Hashtags
@VOYAGE · Post #1698 · 24.03.2026 г., 13:14
🌊 The Areuse River — a natural gem in northeastern Switzerland, carving its way through majestic Alpine landscapes ⛰🌲 Its crystal-clear waters flow through rocky gorges, forming picturesque cascades and waterfalls. Every bend of the Areuse is like a new postcard, filled with wild beauty and peaceful nature 🍃📸 #Switzerland | @voyage
Hashtags
@VOYAGE · Post #1688 · 14.03.2026 г., 13:14
Switzerland🇨🇭 🟠Switzerland is a calm, unhurried, and steadily living country. It does not like upheavals. 🟠It is one of the most beautiful and richest countries in the world, with most of its territory covered by mountains (the Alps and Jura). 🟠Switzerland is a land of stunning alpine landscapes and picturesque small towns, blue lakes reflecting mountains and glaciers, and green valleys. #Switzerland | @voyage
Hashtags
@VOYAGE · Post #1543 · 27.08.2025 г., 12:14
📍Switzerland – a land of stunning Alpine landscapes, picturesque small towns, and blue lakes that reflect the mountains and glaciers. 📏 📏 📏 📏 📏 📏 📏 📏 #Switzerland | @voyage
Hashtags
@VOYAGE · Post #1542 · 26.08.2025 г., 12:14
Switzerland 🇨🇭 Embrace the charm of Swiss villages, indulge in delicious chocolate, and soak in the stunning views that Switzerland has to offer. 🔥 📏 📏 📏 📏 📏 📏 📏 📏 #Switzerland | @voyage
Hashtags
@VOYAGE · Post #1539 · 23.08.2025 г., 12:14
✨This must be what paradise on Earth looks like! 📏 📏 📏 📏 📏 📏 📏 📏 #Switzerland | @voyage
Hashtags
@VOYAGE · Post #1523 · 07.08.2025 г., 12:14
Switzerland🇨🇭 🟠Switzerland is a calm, unhurried, and steadily living country. It does not like upheavals. 🟠It is one of the most beautiful and richest countries in the world, with most of its territory covered by mountains (the Alps and Jura). 🟠Switzerland is a land of stunning alpine landscapes and picturesque small towns, blue lakes reflecting mountains and glaciers, and green valleys. 📏 📏 📏 📏 📏 📏 📏 📏 #Switzerland | @voyage
Hashtags
@VOYAGE · Post #1506 · 22.07.2025 г., 12:14
🏞 Zizikon — a picturesque town on the shores of Lake Lucerne in the heart of Switzerland 🏔 ✨ Here, you can see several historic landmarks, such as the cross chapel, known for its unique architecture, and the ancient Monastery of Santissima Trinitas, which holds centuries of history and spirituality 🙏 📏 📏 📏 📏 📏 📏 📏 📏 #Switzerland | @voyage
Hashtags
@VOYAGE · Post #1504 · 20.07.2025 г., 12:14
🌊 The Areuse River — a natural gem in northeastern Switzerland, carving its way through majestic Alpine landscapes ⛰🌲 Its crystal-clear waters flow through rocky gorges, forming picturesque cascades and waterfalls. Every bend of the Areuse is like a new postcard, filled with wild beauty and peaceful nature 🍃📸 #Switzerland | @voyage
Hashtags
@VOYAGE · Post #1450 · 15.06.2025 г., 12:14
✨This must be what paradise on Earth looks like! 📏 📏 📏 📏 📏 📏 📏 📏 #Switzerland🇨🇭@voyage
Hashtags
@VOYAGE · Post #1434 · 28.05.2025 г., 12:14
📍Switzerland – a land of stunning Alpine landscapes, picturesque small towns, and blue lakes that reflect the mountains and glaciers. 📏 📏 📏 📏 📏 📏 📏 📏 #Switzerland🇨🇭@voyage
Hashtags