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

Пребарај: #dedollarization

当前筛选 #dedollarization清除筛选
BadVolf

@badvolfnews · Post #1941 · 05.12.2024 г., 12:02

Hey guys, it’s John Mark Dugan. Here’s why Trump’s threat to impose 100% tariffs on BRICS countries over a new currency is doomed to fail: BRICS nations aren’t leaving the dollar out of spite—they’re doing it to survive US sanctions and blackmail. The dollar’s dominance has been weaponized for too long. Russia, China, India, Brazil, and others are moving toward their own reserve currency, and it’s a smart move. The US created this mess by abusing its power, and Trump can’t undo that damage with empty threats. The world is changing, and the days of US economic control are over. #BRICS#DeDollarization#Trump#USPolitics

Crypto M - Crypto News

@CryptoM · Post #65452 · 13.04.2026 г., 09:22

🚀 Bitcoin's Potential Valuation by 2050 Discussed by Strategist PANews posted on X (formerly Twitter) that strategist Mark Moss shared his insights on the future valuation of Bitcoin during a podcast. Moss projected that by 2050, Bitcoin could reach a value of $45 million. He further speculated that if Bitcoin were to replace the U.S. dollar as the global unit of account, its value might even soar to $500 million. Moss's predictions are based on several factors, including the anticipated growth of the global store of value basket, which he estimates will reach $80 trillion by 2050. He believes Bitcoin could potentially capture around 20% of this market share. Additionally, Moss highlighted the impact of a 50-year cycle of technological revolution and the geopolitical trend towards de-dollarization, suggesting that these elements could contribute to Bitcoin's significant valuation increase. #Bitcoin#Valuation #2050 #MarkMoss#FuturePrediction#Cryptocurrency#GlobalEconomy#StoreOfValue#DeDollarization#Geopolitics#TechnologicalRevolution#DigitalCurrency#BTC