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

Резултати

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

Пребарај: #cetus

当前筛选 #cetus清除筛选
American Crypto©

@americancryptotrading · Post #27421 · 28.10.2025 г., 09:25

🇺🇸#CETUS/USDT is attempting to bounce from the supportzone on the 3D timeframe💁‍♂️ Looking for a move up📈 American Crypto©

Hashtags

Cetus Announcements

@CetusProtocol · Post #187 · 04.09.2023 г., 12:17

GREAT NEWS🎉@CetusProtocol has officially integrated @DeepBookonSui to be a part of its universal liquidity reserves🐳. Now, traders on #Cetus can enjoy further upgraded liquidity depth & slippage control powered by the seamless fusion of CLMM and CLOB.🥂 1/3🧵 https://twitter.com/CetusProtocol/status/1696197887318008148?s=20

Hashtags

Cetus Announcements

@CetusProtocol · Post #184 · 04.09.2023 г., 12:15

@CetusProtocol is very happy to have integrated 💎Coinbase Pay💎 into its user interface!🔥🎉 With this new integration to be rolled out, users on #Cetus will be given a new choice to quickly purchase crypto and easily start their exploration of DeFi. 🐳@coinbase@CoinbaseCloud https://twitter.com/CetusProtocol/status/1691766911246409975?s=20 @everyone

Hashtags

Cetus Announcements

@CetusProtocol · Post #182 · 03.08.2023 г., 06:13

It's about to enter August. Time to take a look back at what #Cetus accomplished in the past few months👇. The user-oriented product development and iteration will never stop. Keep BUIDLing & stay eager! 🚀🚀🚀 https://twitter.com/CetusProtocol/status/1686027669077417984?s=20 @everyone

Hashtags

Cetus Announcements

@CetusProtocol · Post #180 · 03.08.2023 г., 06:11

Some users may encounter slow loading during the surge in users & concurrent txns🤔. To improve experience, #Cetus now allows users to check real-time RPC node latencies in settings🚦. Users can select a node that shows better performance when they interact with the protocol.🖥🐳 https://twitter.com/CetusProtocol/status/1684832364562931712?s=20 @everyone

Hashtags

Cetus Announcements

@CetusProtocol · Post #170 · 28.06.2023 г., 18:42

We’re happy to integrate to @PythNetwork as the primary price reference source on #Cetus. Traders can have clearer references for their swap decision making. More in-depth integration & collaboration will be carried out as we continue 🔜🔜 https://twitter.com/PythNetwork/status/1674121651758448640?s=20 @everyone

Hashtags

Cetus Announcements

@CetusProtocol · Post #168 · 28.06.2023 г., 18:41

Cetus is super excited to partner with @AlchemyPay🎉🎉, a leading gateway payment provider for transacting between fiat and crypto. Users on #Cetus can now easily make credit card payment in exchange for $CETUS & other mainstream coins via Alchemy Pay. Cheers🍺. https://twitter.com/CetusProtocol/status/1673579065171906561?s=20 @everyone

Hashtags

Cetus Announcements

@CetusProtocol · Post #164 · 28.06.2023 г., 18:39

We are delighted to work with @moledefi, a Sui-based DeFi protocol that provides savings, leveraged yield farms and funds 🎉. Mole is building an one-stop solution that can help users provide liquidity to #Cetus easier and get boosted yields.🚀 https://twitter.com/moledefi/status/1668962317520998402?s=20 @everyone

Hashtags

Cetus Announcements

@CetusProtocol · Post #161 · 07.06.2023 г., 06:28

Happy to launch the Price Range Alerts on Cetus🎉 Powered by @NotifiNetwork, LPs on Cetus can receive alerts via email, sms or telegram msgs if their selected positions go out of range. #Cetus will continue bringing ease & convenience to LPs & traders.👇 https://twitter.com/cetusprotocol/status/1666330270377844736?s=46&t=IcRwi54TUHq01WguSKBieA @everyone

Hashtags

123•••910
ПретходнаСтраница 1 од 10Следна