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

Резултати

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

Пребарај: #pha

当前筛选 #pha清除筛选
Coin Sonar

@CoinSonar · Post #243495 · 17.04.2026 г., 07:09

#PHA | Volume spike (USDT PAIR) 21 times the average volume 128.41K USDT traded in 15 min └Buying vol: 83.38K USDT 🟢 Boost score: 6/10 24h Vol: 563.58K USDT (Binance) Price: 0.0391 (-6.0% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #28508 · 01.03.2025 г., 19:27

#PHA/USDT analysis : #PHA has experienced a breakout followed by a retest of the support zone. The price is now anticipated to continue its downward trajectory and test lower levels. This bearish outlook is supported by the breakout and retest pattern, suggesting a potential continuation of the downtrend. TF : 4H Entry : $0.1465 Target : $0.1146 SL : $0.1642

Hashtags

American Crypto©

@americancryptotrading · Post #27222 · 18.04.2025 г., 15:36

🇺🇸#PHA/USDT has broken above the descendingresistance on the daily chart🔥 Pump is coming🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27140 · 02.02.2025 г., 19:27

🇺🇸#PHA/USDT is testing the broken s/rzone on the weekly chart🔍 Bullish if we bounce🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27038 · 03.11.2024 г., 14:01

🇺🇸#PHA/USDT maintaining keysupport on weekly timeframe👨‍💻 Expecting nice upside move from these levels📈 American Crypto©

Hashtags

Crypto Profit Coach™

@cryptoprofitcoach · Post #9138 · 09.05.2025 г., 15:53

#PHA👈💲 https://www.binance.com/en/trade/PHA_BTC Buying Zone 123-130 👆 Sitting at bottom Sell 🤑 142-150 🤑 150-160 🚀 160-185 💃 185-200 & above Bullish above 115🔼🔼 Death Zone below 115🔽🔽

Hashtags

ПретходнаСтраница 1 од 3Следна