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

Резултати

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

Пребарај: #security

当前筛选 #security清除筛选

Rekt News | 𝕏🧵 A $300M AI project @_Qubic_ claimed it conquered a $6Bprivacy giant with a "51% attack" on Monero. Community sleuths called BS - actual hashrate closer to 30%. Meanwhile, $qubic tokens burned by the billions. Market moved, story spread, receipts didn't add up. Story below... ~ ₿izFeed#⃣:#security

Hashtags

Rekt News | 𝕏🧵 The Rekt Leaderboard is a warning label. Some were “audited” (wrong scope, ignored deploy scripts, no oracle model). Others skipped audits entirely and learned on-chain. Clean PDFs don’t stop dirty exploits. Process does. Submit once, get multiple vetted bids. club.rekt.news/audit-broker ~ ₿izFeed#⃣:#security

Hashtags

EthSecurity | 𝕏 Bepop DM me and claimed they haven’t been hacked and the issue was not on bepop’s side. Victim wallet: 0x4a4a2fA0Cf9EE113b9d026E93eDd835EDae048Eb Bebop contract: 0xbeb0b0623f66be8ce162ebdfa2ec543a522f4ea6 Attacker proxy contract: 0xA40a67FD44E5972eA8720a79E35D74E262A38e3C Attacker wallet: 0xf0d997D59Ffc4d114Aa362B0d0431847C25BfB45 Token: WHYPE 0x5555555555555555555555555555555555555555 @EthSecurity1 ~ ₿izFeed#⃣:#security

Hashtags

EthSecurity | 𝕏 24 hours ago, @numamoney got hacked again. The root cause? A 0.6 discount sneaks into the minting process because of some janky fee logic. Yeah, you heard that right—minting at a discount! That’s the kind of bug that makes you wonder who’s even auditing this stuff. The first time is a mistake, the second time is a choice. https://sonicscan.org/tx/0x56abdbc84232658617853f233f52e6b4c855129c7ab163a588c2bac62ea30408 @EthSecurity1 ~ ₿izFeed#⃣:#security

Hashtags

Indian Development News 🇮🇳

@developmentnewsindia · Post #43834 · 20.04.2026 г., 05:29

Lashkar terrorist Umar, alias "Kharghosh," managed to procure a passport from India and fled to Indonesia. From there, he is believed to have used another forged travel document to establish himself in a Gulf country. BUT, NOT ANYMORE !!!! He has now been arrested in Saudi Arabia. A high value target. Expect more bust of Lashkar network in Kashmir and across India. Kudos to Indian intelligence. #security

Hashtags

Кир Стармер собирается предложить союзникам новую оборонную инициативу Премьер-министр Великобритании Кир Стармер на Мюнхенской конференции по безопасности планирует продвигать идею новой оборонной инициативы. Об этом сообщает газета Financial Times. Речь идет о более тесной координации закупок вооружений и снижении затрат на перевооружение. По данным британских правительственных источников, завтра, 14 февраля, Стармер намерен публично призвать к «более тесному оборонному сотрудничеству с союзниками» и обсудить эту тему в закрытых переговорах с лидерами других стран. #Security

Hashtags

123•••10•••20•••2728
ПретходнаСтраница 1 од 28Следна