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

Резултати

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

Пребарај: #adx

当前筛选 #adx清除筛选
Pro Analysis

@proanalysistrader · Post #28558 · 19.03.2025 г., 04:28

#ADX/USDT analysis : #ADX is currently in a downtrend and trading below its 200 exponential moving average (EMA). The price is encountering resistance from the 200 EMA and a resistance zone. It is anticipated that the price will decline from this point and test lower levels. TF : 2h Entry : $0.1090 Target : $0.0963 SL : $0.1173

Hashtags

Pro Analysis

@proanalysistrader · Post #28099 · 31.10.2024 г., 13:16

#ADX/USDT analysis : #ADX is currently in an uptrend, making new highs while trading above the 200 EMA and the support zone. The price is anticipated to resume its bullish momentum and test the previous swing high. Look for a pullback for a long entry. TF : 4H Entry : $0.1659 Target : $0.1934 SL : $0.1550

Hashtags

Crypto Profit Coach™

@cryptoprofitcoach · Post #9086 · 24.11.2024 г., 04:03

#ADX👈 https://www.binance.com/en/trade/ADX_BTC Buying Zone 186-200 👆 Sell 🤑 220 🤑 220-240 🚀 240-260 💃 260-280 😱 280- 300 & above Bullish above- 175🔼 Death Zone below-175 🔽

Hashtags

Crypto Profit Coach™

@cryptoprofitcoach · Post #9063 · 06.09.2024 г., 15:20

#ADX profit projections if remains in bull zone Strong support Layer 220-225 Above this value #ADX will remain in bull Zone and will go as projected 🚀🚀

Hashtags

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