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

Резултати

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

Пребарај: #usfinance

当前筛选 #usfinance清除筛选
Venture Village Wall 🦄

@venturevillagewall · Post #3964 · 23.01.2025 г., 22:00

Trump Launches National Crypto Strategy 🚨 President Trump has signed an executive order to establish a Presidential Working Group on Digital Asset Markets. This group will push for a robust regulatory framework for cryptocurrencies and stablecoins, and explore the creation of a National Digital Asset Stockpile using seized digital assets. Chaired by crypto advocate David Sacks, the group aims to strengthen U.S. leadership in digital finance and replace previous regulations seen as obstacles to innovation. Full details: Leviathan News #Trump#Crypto#DigitalAssets#Bitcoin#Stablecoins#NationalReserve#USFinance#Blockchain#Innovation#CryptoWorkingGroup

Crypto M - Crypto News

@CryptoM · Post #64737 · 09.04.2026 г., 16:54

🚀 U.S. March Budget Deficit Estimated at $163 Billion The U.S. Congressional Budget Office (CBO) has announced that the budget deficit for March is projected to reach $163 billion. According to BlockBeats, this estimate reflects ongoing fiscal challenges faced by the United States. The CBO's report highlights the financial pressures impacting the federal budget, as expenditures continue to outpace revenues. This development underscores the importance of addressing the nation's fiscal policies to manage the growing deficit effectively. #USBudget#BudgetDeficit#FiscalPolicy#CBO#USFinance#FederalBudget#Economy#MarchDeficit#FinancialReport#USGovernment

Crypto M - Crypto News

@CryptoM · Post #65191 · 11.04.2026 г., 18:19

🚀 U.S. Public Debt Increases by $571.28 Billion, Reaching $38.969 Trillion The United States public debt has increased by approximately $571.28 billion this year, reaching a total of $38.969 trillion as of April 7, 2026. According to NS3.AI, this figure encompasses both debt held by the public and intragovernmental holdings. In an interview with NPR, JPMorgan Chase CEO Jamie Dimon expressed concerns that the growing debt burden could pose challenges, potentially leading to higher market rates and reduced demand for U.S. Treasurys. #USDebt#PublicDebt#USFinance#GovernmentDebt#EconomicNews#USMarkets#Treasury#DebtCrisis#JPMorgan#Macroeconomics

Venture Village Wall 🦄

@venturevillagewall · Post #4357 · 10.03.2025 г., 22:00

Crypto News: Market Decline and Developments 🇺🇸 Sunnyvale Public Safety Officers Association becomes the first U.S. dual-agency to hold Bitcoin on its balance sheet. Joseph Lubin praises U.S. government's reforms, anticipating crypto growth by 2025. President Trump's upcoming executive order may adjust Fed policies for crypto banks and clarify that stablecoins are not securities. FIFA considering a new cryptocurrency, FIFA Coin, to engage 5 billion fans. Coinbase to hire 1,000 workers, citing Trump's positive impact on the crypto industry. Ethereum sees significant outflows totaling $1.8 billion, while total value locked in DeFi drops to $88 million. Bitcoin's price fluctuates between extreme greed and fear, with a current value of $79,000. Ethereum declines below $2000, triggering market fears as total market cap falls by 33%. Current index shows extreme fear since 2022, affecting trader sentiments. #Bitcoin#Crypto#DeFi#TrumpsExecutiveOrder#FIFA#Ethereum#Coinbase#Stablecoins#MarketSentiment#Bullish#Blockchain#Investors#CryptoRegulation#ETH#USFinance#DigitalAssets#CryptoOutflows#FinanceNews