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

Пребарај: #bitcoingrowth

当前筛选 #bitcoingrowth清除筛选
Crypto M - Crypto News

@CryptoM · Post #65309 · 12.04.2026 г., 19:56

🚀 Strategy Requires 2.05% Annual Bitcoin Growth to Sustain Dividends, Says Michael Saylor Michael Saylor has stated that Strategy needs an annual Bitcoin growth rate of 2.05% to cover its preferred stock dividends without the need to issue new common shares. According to NS3.AI, Strategy's dashboard indicates that the company holds 766,970 BTC, providing approximately 48.7 years of dividend coverage at the current reserve levels. The current annual yield for STRC stands at 11.5%. #Bitcoin#MichaelSaylor#STRC#Dividends#CryptoInvestment#Cryptocurrency#BitcoinGrowth#PreferredStock#InvestmentStrategy#BTC

Crypto M - Crypto News

@CryptoM · Post #64628 · 09.04.2026 г., 11:57

🚀 Bitcoin Bancorp Expands Bitcoin ATM Network in Southern California Bitcoin Bancorp has announced the launch of a licensed Bitcoin ATM network in Southern California, with the first machines now operational in the Los Angeles area. According to Odaily, this marks a new phase in the company's retail expansion in the United States, following its previous deployment in Texas, highlighting its strategy to accelerate growth in key markets. Data indicates that the United States currently hosts over 35,000 Bitcoin ATMs, with the industry expected to grow from approximately $267 million in 2025 to $7.68 billion by 2034. California, with its large population, advanced tech ecosystem, and high rate of cryptocurrency adoption, is a significant growth market, ranking among the top states in the nation for ATM installations, second only to states like Texas. #BitcoinBancorp#BitcoinATM#SouthernCalifornia#LosAngeles#RetailExpansion#Cryptocurrency#BitcoinMarket#CaliforniaTech#CryptoAdoption#USBitcoinATMs#ATMInstallations#BitcoinGrowth#BTC