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

Резултати

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

Пребарај: #creativetech

当前筛选 #creativetech清除筛选
ChatGPT AI Technology News

@chatgpt_officialnews · Post #71 · 26.03.2025 г., 21:16

Hey AI lovers! Big news in the world of AI creativity: with GPT-4o, you can now create and customize images just by describing what you want! Whether it’s a specific aspect ratio, exact colors (using hex codes like #FF5733 for a vibrant orange), or even a transparent background—GPT-4o makes it happen with a simple chat. Imagine designing a futuristic cityscape in neon blues (#00C4FF) and purples (#800080), or a minimalist logo with a 1:1 aspect ratio and a transparent background for your next project—all without touching a design tool! The possibilities are endless. ➖➖➖➖🔻 💎@Chatgpt_OfficialNews – Stay Updated! ⚡️ 🧠 BOT: @Chatgpt_OfficialBOT #️⃣#OpenAI #N#AI #GPT4o#ImageGeneration#CreativeTech#Design ➖➖➖➖🔺

GAMEFEST.UZ

@gamefestuz · Post #274 · 07.04.2026 г., 05:08

O‘zbekiston o‘yin sanoati tarixida yangi sahifa! Biz Game Fest 2026 doirasida navbatdagi maxsus mehmonimizni e’lon qilishdan faxrlanamiz. 🌍HOMA GAMES — ENDI TOSHKENTDA! Homa Games - bu dunyo miqyosidagi mobil o‘yinlar nashriyoti (publisher) bo‘lib, ularning portfelidagi o‘yinlar 1 milliarddan ortiq marta yuklab olingan! Ular "Hyper-casual" va "Hybrid-casual" yo‘nalishlarida dunyo yetakchilari hisoblanadi. Nega bu siz uchun muhim? 📌 Direct Pitching: O‘z o‘yiningizni dunyodagi eng kuchli nashriyotlardan biriga shaxsan taqdim etish imkoniyati. 📌 Market Insights: Homa Lab texnologiyalari va o‘yinlarni global darajaga olib chiqish sirlari haqida eksklyuziv bilimlar. 📌 ScaleUp: Loyihangizni jahon bozoriga olib chiqish va investitsiya jalb qilish uchun eng qisqa yo‘l. Creative Tech va Game Fest 2026 - bu shunchaki festival emas, bu sizning global karyerangiz boshlanish nuqtasidir. 📅Sana: 2026-yil, 15-16 may 📍Manzil: Renaissance Hall, Toshkent 🏛Tashkilotchi: O‘zbekiston Kreativ uyushmasi 🚀O‘z o‘yiningizni dunyoga ko‘rsatishga tayyormisiz?🌐 Batafsil va ro‘yxatdan o‘tish: CreativeTech.uz 📢 Kanalimiz: @creative_tech_official 📞 Aloqa: +998-95-474-19-19 ————————— A New Chapter for Uzbekistan’s Gaming Industry! 🚀🎮 We are thrilled to announce our next special guest for Game Fest 2026 ! Join us as we welcome a global powerhouse to Tashkent: 🌍 HOMA GAMES — NOW IN UZBEKISTAN! Homa Games is a world-class mobile games publisher with over 1 billion downloads across their portfolio. They are undisputed global leaders in the "Hyper-casual" and "Hybrid-casual" sectors. Why is this a game-changer for you? 📌 Direct Pitching: A rare opportunity to present your game personally to one of the world’s most influential publishers. 📌 Market Insights: Gain exclusive knowledge on Homa Lab technologies and the secrets to scaling games to a global audience. 📌 ScaleUp & Funding: The fastest route to taking your project to the international market and securing professional backing. Creative Tech & Game Fest 2026 is more than just a festival—it is the launchpad for your global career. 📅 Date: May 15-16, 2026 📍 Venue: Renaissance Hall, Tashkent 🏛 Organizer: Uzbekistan Creative Association 🚀 Ready to show your game to the world? 🌐 Details & Registration: CreativeTech.uz 📢 Follow us: @creative_tech_official 📞 Contact: +998-95-474-19-19 #GameFest2026#HomaGames#GamedevUzbekistan#CreativeTech#AnimationUz#GameDev#TashkentEvents