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

Пребарај: #supercomputing

当前筛选 #supercomputing清除筛选
AI & Law

@ai_and_law · Post #340 · 27.06.2024 г., 07:04

EU Council Adopts Regulation to Boost AI Development with Supercomputing Power The Council of the EU has officially adopted an amendment to the regulation on the European High-Performance Computing (EuroHPC) joint undertaking, paving the way for the creation of AI factories. With this regulation, the EuroHPC initiative will promote AI factories that include AI supercomputers, associated data centers, and specialized supercomputing services. These facilities will provide both public and private users with access, with specific conditions tailored for startups and SMEs. Host entities of AI factories will receive EU financial support, covering up to 50% of both acquisition and operating costs of AI supercomputers. The regulation will be published in the Official Journal of the European Union and will enter into force 20 days later, marking a significant step towards enhancing AI development and innovation across Europe. #AI#Supercomputing

科技&趣闻&杂记

@kejiqu · Post #4338 · 09.04.2026 г., 10:13

黑客声称从中国国家超级计算中心窃取 10 PB 敏感数据,此举将成为中国历史上最大规模的网络攻击,涉及科学、国防等领域 6,000 个客户 黑客声称已从中国国家超级计算中心窃取高达 10 petabytes 的敏感数据,如果属实,这将成为中国历史上规模最大的网络攻击事件。此次攻击影响范围广泛,涉及约 6,000 个客户,涵盖科学、国防等多个领域。目前事件的真实性尚未得到独立验证,但黑客声称掌握了大量敏感信息。安全专家正在对此事件进行分析。Tom's Hardware 🏷#China#National#Supercomputing#Center#petabytes#data#breach 📢频道👥群组📝投稿