@naturetravelvacationpictures · Post #403 · 04.04.2019 г., 02:30
🌿❤️✨🍃 Sunrays...🌞 #Water#Nature#Cave Join Us ✅🔜@Discover_Nature 🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃
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
Пребарај: #cave
@naturetravelvacationpictures · Post #403 · 04.04.2019 г., 02:30
🌿❤️✨🍃 Sunrays...🌞 #Water#Nature#Cave Join Us ✅🔜@Discover_Nature 🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃🍃
@bestwallpapes · Post #3245 · 22.01.2025 г., 13:55
@Bestwallpapes #Nature#Cave#Mountain
@interesting_planet_facts · Post #1200 · 07.01.2026 г., 12:11
🌎 Hidden beneath Slovakia, the Ochtinská Aragonite Cave is famous for its rare aragonite crystal formations, which look like tangled white “coral.” Its passages were naturally formed in Paleozoic-era rocks about 400 million years ago. The cave stretches only 300 meters but contains aragonite speleothems found in just a few caves worldwide. ✨ #cave⚡#geology⚡#minerals 👉subscribe Interesting Planet 👉more Channels
@interesting_planet_facts · Post #1070 · 25.11.2025 г., 12:11
🌎 Beneath the waters of the Bahamas, the so-called “blue holes” are deep, vertical underwater caves formed during past ice ages when sea levels were lower. Some exceed 300 meters in depth and preserve ancient fossils and climate records in their oxygen-poor layers. ✨ #ocean⚡#cave⚡#paleoclimate 👉subscribe Interesting Planet 👉more Channels
Hashtags
@expeditionsworldwide · Post #488 · 03.07.2023 г., 13:03
🫶 Dear subscribers! We delighted that you're following our channel! On our channel, you'll find everything about travel! By using hashtags, you can easily find the content that interests you. CHANNEL CONTENT: 📹#videoclips 🧭#expedition 🏔️#hiking 🤿#diving 🧨#unusualplaces ⛩#bridges 🏔#mountains ⌛️#facts ✈️#airplanecemeteries 🗻#hills 🏜#discoveries 🏖#beaches 🈴#China 🕌#India 💒#temples 🏤#architecturalmasterpieces 🚆#journeys 🏜#vacations 🎇#UNESCO ⛰#cliffs 🌋#canyon 🌊#lakes 🏢#skyscrapers ⛲️#waterfalls ⛴#dam 🏕#inaccessibleplaces 🌋#volcano 🚀#traveladvice 🌊#sea 🌲#forest 🏝#island 🌅#desert 🌫#ponds ⛰#cave ⭐️#travelhacks ⛺️#nationalpark Thank you for being a part of our travel community! Happy exploring! 🪐Discover upcoming expeditions — https://4elementos.shop
Hashtags