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

Резултати

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

Пребарај: #paymentsystems

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

@venturevillagewall · Post #3672 · 21.12.2024 г., 18:50

Sheldon Schiff Proposes USAcoin Peter Schiff advocates replacing Bitcoin as a strategic US reserve with a new crypto asset, USAcoin, featuring a limited supply of 21 million coins and an improved blockchain for better payment capability. He highlights this shift as a pathway to wealth, contrasting his views on Bitcoin, which he refers to as digital gold. Schiff also generated an image with Elon Musk and Donald Trump against a Bitcoin backdrop, criticizing ChatGPT for its content restrictions. _"HODL to the Moon, America!"_ #PeterSchiff#USAcoin#Crypto#Bitcoin#Blockchain#Investment#DigitalGold#Wealth#PaymentSystems#Grok

Crypto M - Crypto News

@CryptoM · Post #65365 · 13.04.2026 г., 02:44

🚀 Hong Kong's Cautious Approach to Digital Asset Licensing Hong Kong's Financial Secretary, Paul Chan, has outlined a cautious strategy for issuing digital asset licenses. According to Foresight News, Chan emphasized a 'small steps, quick progress' approach, initially granting a limited number of licenses. The focus is on practical application scenarios, with plans to evaluate experiences before issuing a second batch. Chan highlighted that stablecoins and digital assets represent financial innovation, requiring encouragement for breakthroughs. However, he stressed the importance of maintaining security and implementing mechanisms to prevent money laundering, necessitating appropriate regulation. While stablecoins offer benefits such as decentralization and high efficiency, Chan noted they should be viewed as payment tools rather than investment instruments. #HongKong#DigitalAssets#FinTech#Stablecoins#FinancialRegulation#CryptoLicensing#Innovation#AML#PaymentSystems

Venture Village Wall 🦄

@venturevillagewall · Post #4295 · 03.03.2025 г., 13:00

Trump Announces National Crypto Reserve 🇺🇸 President Trump announces plans for a U.S. national crypto reserve, including assets like XRP, SOL, and ADA. He established a presidential working group to strategize this reserve. The announcement has sparked controversy, with accusations of insider trading and mixed opinions on asset choice. Bitcoin and Ethereum will also play significant roles in the reserve. Read more details here. #Crypto#XRP#Bitcoin#Ethereum#SOL#ADA#US#Reserve#InsiderTrading#Blockchain#Trump#Finance#Investments#VC#Regulation#DigitalAssets#Stablecoins#PaymentSystems

Venture Village Wall 🦄

@venturevillagewall · Post #3669 · 21.12.2024 г., 13:51

USAcoin Proposal by Peter Schiff Peter Schiff suggests that instead of building a strategic reserve in BTC, the U.S. could save money by launching a new cryptocurrency called USAcoin, which would have a capped supply of 21 million coins, utilizing updated blockchain technology for payment efficiency. He emphasizes the potential wealth this could generate and encourages HODL. 🔗Read more here🔗Join Crypto Twitter #USAcoin#Cryptocurrency#BTC#Blockchain#PaymentSystems#Investment#WealthBuilding#HODL#Crypto#Finance#PeterSchiff#CryptoTwitter#DigitalCurrency