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 слични објави

Пребарај: #2026amnestylaw

当前筛选 #2026amnestylaw清除筛选
Venezuelanalysis

@venanalysis · Post #2282 · 23.02.2026 г., 14:10

📰 NEWS | Venezuelan Parliament Approves Amnesty Law, Rodríguez Calls for ‘Peace and Tolerance’ Venezuela’s National Assembly has passed the Amnesty Law for Democratic Coexistence, establishing a blanket amnesty for crimes committed in the context of political violence between 1999 and 2026. The legislation references events including the 2002 coup attempt, the 2014 and 2017 protests, and unrest following the July 2024 presidential elections. Article 7 excludes serious human rights violations, crimes against humanity, war crimes, homicide, corruption offenses in public office, and drug trafficking with sentences exceeding nine years. Parliament created a Special Monitoring Commission to oversee implementation. According to its president, 379 amnesty requests have been processed, with further cases under revision. Read our full report here 👉🏾https://venezuelanalysis.com/news/venezuelan-parliament-approves-amnesty-law-rodriguez-calls-for-peace-and-tolerance/ #2026AmnestyLaw#Opposition

Venezuelanalysis

@venanalysis · Post #2273 · 10.02.2026 г., 14:08

📰 NEWS | Venezuelan Authorities Begin Consultations on Amnesty Law The Venezuelan National Assembly has begun nationwide consultations on a preliminarily approved “Amnesty Bill for Democratic Coexistence,” holding meetings with community peace judges, civil society organizations and university law faculties. Lawmakers said the process aims to gather input before a revised version is submitted for a final vote in the coming weeks. The bill seeks to pardon political and related crimes committed between January 1, 1999, and January 30, 2026, while explicitly excluding serious human rights violations, crimes against humanity, homicide, drug trafficking and corruption. Former Spanish President José Luis Rodríguez Zapatero endorsed the initiative during a meeting in Caracas, describing it as a turning point for national reconciliation. Read the full report here 👉https://venezuelanalysis.com/news/venezuelan-authorities-begin-consultations-on-amnesty-law/ #2026AmnestyLaw#Opposition

Venezuelanalysis

@venanalysis · Post #2286 · 28.02.2026 г., 00:00

📰 NEWS | Venezuela: Attorney General and Ombudsman Resign as Authorities Process Thousands of Amnesty Requests National Assembly President Jorge Rodríguez confirmed the resignations of Attorney General Tarek William Saab and Ombudsman Alfredo Ruiz. Parliament declared urgency, formed a 13-member committee to appoint new officials within 30 days, and named interim replacements. The developments come as authorities process Amnesty Law requests covering cases dating back to 1999. Deputy Jorge Arreaza reported 8,110 petitions filed since approval last week, with 4,757 individuals benefiting so far, including 223 released from prison and 4,534 cleared of parole-type measures. Read our full report here: https://venezuelanalysis.com/news/venezuela-attorney-general-and-ombudsman-resign-as-authorities-process-thousands-of-amnesty-requests/ #2026AmnestyLaw#NationalAssembly#TarekWilliamSaab