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

Резултати

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

Пребарај: #yfi

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

@CoinSonar · Post #243683 · 17.04.2026 г., 13:32

#YFI | Volume spike (USDT PAIR) 35 times the average volume 128.87K USDT traded in 15 min └Buying vol: 115.16K USDT 🟢 Boost score: 4/10 24h Vol: 346.65K USDT (Binance) Price: 2768 (+0.5% in 24h)

Hashtags

Pro Analysis

@proanalysistrader · Post #28172 · 12.11.2024 г., 14:25

#YFI/USDT analysis : #YFI is currently experiencing a downtrend on the higher time frame. The price has retraced to a resistance zone during the correction phase. Currently, the price is exhibiting signs of rejection from this zone. It is anticipated that the price will decline from this point and test the previous swing low. TF : 1D Entry : $6,227 Target : $4,460 SL : $7,306

Hashtags

American Crypto©

@americancryptotrading · Post #27609 · 04.05.2026 г., 09:08

🇺🇸#YFI/USDT is holding above the lowerboundary of the fallingwedge pattern on the 2W chart🧐 Looking for a rise📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27145 · 05.02.2025 г., 19:25

🇺🇸#YFI/USDT is attempting to bounce from the supportzone on the weekly timeframe👀 Accumulate here for the medium term🐃 American Crypto©

Hashtags

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