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

Резултати

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

Пребарај: #rsr

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

@proanalysistrader · Post #28518 · 05.03.2025 г., 09:32

#RSR/USDT analysis : The #RSR price is currently in a bearish trend and has established new lows. The price is expected to continue its downward movement and test lower levels. For short entry, consider waiting for the price to touch the resistance zone. TF : 2H Entry : $0.007040 Target : $0.005453 SL : $0.008022

Hashtags

Pro Analysis

@proanalysistrader · Post #28352 · 21.12.2024 г., 09:52

#RSR/USDT analysis : #RSR has retraced and tested a key support zone, facing immediate rejection that formed a bullish rejection candle. This suggests strong buying interest, the price is expected to rebound from this level and resume its bullish momentum, potentially testing previous highs. TF : 1D Entry : $0.01170 Target : $0.02570 SL : $0.00864

Hashtags

American Crypto©

@americancryptotrading · Post #27223 · 19.04.2025 г., 17:23

🇺🇸#RSR/USDT is bouncing off the broken descendingresistance line on the daily chart👨‍💻 Looks good to buy📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27192 · 21.03.2025 г., 17:07

🇺🇸#RSR/USDT is holding above the broken descendingresistance on the weekly chart🧐 More upside is coming📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27044 · 09.11.2024 г., 14:53

🇺🇸#RSR/USDT is testing the s/r zone right now on weekly timeframe👀 Bullish if breaks above the one🐃 American Crypto©

Hashtags

Crypto

@signal_bitcoins · Post #2711 · 08.02.2024 г., 15:05

#RSR pullback done to the broken falling wedge pattern on Weekly time frame,we are waiting for the next movement right now 👀 ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️

Hashtags

Crypto

@signal_bitcoins · Post #2223 · 08.01.2024 г., 12:51

#RSR broken down the Bearish channel on Daily time frame,we expect more correction after a pullback to the bottom of broken channel 📉 ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️

Hashtags

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