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

Резултати

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

Пребарај: #cevfawards2025

当前筛选 #cevfawards2025清除筛选
IT Park Ventures

@ITParkVentures · Post #117 · 15.03.2025 г., 04:10

“IT Park Ventures” - “Central Eurasian Venture Forum (CEVF) Awards 2025” uchun nomzodlar qabul qilish jarayonini rasman boshlangani haqida e’lon qiladi. Ushbu nufuzli tashabbus Markaziy Yevroosiyodagi startap va venchur ekotizimiga qo‘shilgan ulkan hissalarni e’tirof etadi, va fondning asosiy hamkorlaridan biri – MOST Ventures tomonidan tashkil qilinmoqda. ✨Innovatsiya va investitsiyalardagi yuksak muvaffaqiyatlarni sharaflaymiz “CEVF Awards” mintaqaning startaplar va venchur ekotizimidagi eng taʼsirchan ishtirokchilarini eʼtirof etadi. Tanlov doirasida “Eng tez rivojlanayotgan startap”, “Eng yaxshi venchur fond” va boshqalar kabi nufuzli nominatsiyalar taqdim etiladi. 🗓Tadbir tafsilotlari 📍 Taqdirlash marosimi: 2025-yil 5-iyun | Swissotel Almaty ⭐️Nomzodlarni qabul qilish muddati: 2025-yil 1-aprel 💡 Innovatsiyalarni qayta belgilayotgan startap, investor yoki yetakchini bilasizmi? Ularni (yoki oʻzingizni!) nomzod sifatida koʻrsating va ushbu nufuzli tadbirning bir qismiga aylaning. 🔗 Nomzodingizni yuborish: ventureforum.asia/nominations 📧 Bogʻlanish uchun: [email protected] — IT Park Ventures is proud to announce the call for applications for the Central Eurasian Venture Forum (CEVF) Awards 2025—a prestigious celebration of visionaries, innovators, and investors shaping the future of technology and entrepreneurship in Central Eurasia organized by one of the fund’s key partners - MOST Ventures. ✨ Honoring Excellence in Innovation & Investment The CEVF Awards spotlight the most impactful players in the region’s startup and venture ecosystem, recognizing categories such as Fastest Growing Startup, Best Venture Fund, and more. 🗓Key Event Details 📍 Awards Ceremony: June 5, 2025 | Swissotel Almaty ⭐️ Nomination Deadline: April 1, 2025 💡 Do you know a startup, investor, or leader redefining innovation? Nominate them (or yourself!) and be part of this prestigious celebration of success. 🔗 Submit your nomination: ventureforum.asia/nominations 📧 Contact: [email protected] #CEVFAwards2025#Innovation#VentureCapital#Startups