@bizfeed · Post #332460 · 14.08.2025 г., 22:39
DL News | News Feed | ꘜ Crypto exchanges should block users from cashing out tokens with low ‘compliance scores,’ BIS researchers say ~ ₿izFeed#⃣:#cryptonews
Hashtags
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
Пребарај: #cryptonews
@bizfeed · Post #332460 · 14.08.2025 г., 22:39
DL News | News Feed | ꘜ Crypto exchanges should block users from cashing out tokens with low ‘compliance scores,’ BIS researchers say ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332448 · 14.08.2025 г., 21:18
The Block | 𝕏 David Bailey’s Nakamoto and KindlyMD close merger for Bitcoin treasury ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332447 · 14.08.2025 г., 21:14
unfolded. | ꘜ Long-term holders still command ~85% of all Bitcoin—near a historic high—while net outflows continue to drain exchange inventories, creating an increasingly illiquid float that can magnify price moves — link | AI comment ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332446 · 14.08.2025 г., 20:39
Blockworks | ꘜ Charting the course 📊 https://blockworks.co/news/the-state-of-solana-charts ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332445 · 14.08.2025 г., 20:39
The Block | 𝕏 US Justice Department unseals warrant to seize millions in crypto from alleged ransomeware operator ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332434 · 14.08.2025 г., 20:04
The Block | 𝕏 Bitcoin miner TeraWulf shares jump 50% after Google secures 8% stake as part of $3.7 billion 10-year AI compute deal ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332432 · 14.08.2025 г., 19:44
Blockworks | ꘜ To cut or not to cut...that is the question https://blockworks.co/news/outlining-fed-rate-cut-scenarios ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332429 · 14.08.2025 г., 19:14
The Block | 𝕏 Bitcoin Layer 2 Bitlayer raises additional $5 million in oversubscribed public token rounds on decentralized crowdfunding platforms ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332417 · 14.08.2025 г., 18:54
Blockworks | ꘜ Circle one: - Rollup - L1 https://blockworks.co/news/circle-l1-impact-ethereum ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332416 · 14.08.2025 г., 18:54
DL News | News Feed | ꘜ The US ‘won’t buy’ more Bitcoin, says Treasury Secretary ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332415 · 14.08.2025 г., 18:54
unfolded. | ꘜ Citigroup considers custody and payment services for stablecoins, crypto ETFs — link | AI comment ~ ₿izFeed#⃣:#cryptonews
Hashtags
@bizfeed · Post #332414 · 14.08.2025 г., 18:33
The Block | 𝕏 The Daily: Bessent says govt won't buy bitcoin for strategic reserve, Ethereum ICO whale sells another $5 million in ETH, and more ~ ₿izFeed#⃣:#cryptonews
Hashtags