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

Резултати

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

Пребарај: #medicalbreakthrough

当前筛选 #medicalbreakthrough清除筛选
America 🇺🇸 News & Politics

@America · Post #10378 · 12.03.2026 г., 06:00

💊🇺🇸FDA APPROVES BREAKTHROUGH DRUGS FOR RARE DISEASES 🔹 Yuviwel approved Feb 27 for dwarfism growth — first-ever treatment for kids 👶 🔹 Loargys gets green light for ultra-rare Arginase 1 Deficiency 🧬 🔹 Bysanti breakthrough schizophrenia drug hits market February 20th 🧠 🔹 Wellcovorin approved March 10 for cerebral folate deficiency 🧪 🔹 Takeda's narcolepsy drug oveporexton submits for late March review 😴 5 novel drug approvals in first quarter — fastest pace since 2023! 📈 Rare disease patients get hope as FDA accelerates orphan drug pipeline... 🙏✨ #FDA#MedicalBreakthrough#RareDiseases#DrugApproval @america

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40408 · 25.12.2025 г., 11:03

Amanda Smith, 35, had Type 1 diabetes and needed insulin daily. In February 2023, doctors gave her new islet cells made from stem cells. By August, she no longer needed insulin because her body made it again. This treatment helped her live without constant insulin shots.💉🧬 [Read more] @googlefactss #StemCellTherapy#DiabetesTreatment#HealthFacts#MedicalBreakthrough

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40834 · 20.03.2026 г., 15:04

New kidney treatments help people with kidney disease protect and preserve their kidney function. New drugs slow disease progression. Doctors can target the exact cause of kidney problems. Early tests catch issues sooner, and combination therapies help manage complications like anemia. People with kidney disease have more options to maintain their health. 🩺💊🧬✨ [Read more] @googlefactss #KidneyHealth#CKD#MedicalBreakthrough#EarlyDetection#PrecisionMedicine#HealthyLife