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

Резултати

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

Пребарај: #trxusdt

当前筛选 #trxusdt清除筛选
We want you

@we_want_youu · Post #4278 · 18.08.2024 г., 01:51

In a situation where the market is not in a good condition, #TRXUSDT's trend is still upward. After reaching the bottom of the channel and the support level of $0.1100-0.1050, the price started to grow and first broke the small dynamic resistance. According to the general situation of this currency and the registered candles, it can be expected that the price will grow again up to the ceiling of the channel.

Hashtags

Haydar Sabiev | Crypto Investor

@haydarcrypto · Post #23 · 12.10.2023 г., 10:06

Signal for a futures trade #TRXUSDT.P 📌 Logged into SHORT Entry: ±$0.08521 Take profit: $0.084; $0.082; $0.0805 Stop loss: $0.0867 The price broke through the trend support and left the bottom. Also against the downside is a “flat-bottomed triangle” formation. I expect the decline to continue.

Hashtags

Elf Crypto VIP

@elfcryptovip · Post #12413 · 30.12.2025 г., 08:12

🚨Candlestick Patterns Detected: 🔨Hammer#STORJUSDT 🔨Hammer#ATUSDT 🔨Hammer#ASTERUSDT 🔨Hammer#AVAXUSDT 🔨Hammer#DOTUSDT 🔨Hammer#DOGEUSDT 🔨Hammer#SOLUSDT ⭐Shooting Star#ADAUSDT ⭐Shooting Star#ETHUSDT ⭐Shooting Star#XRPUSDT ⭐Shooting Star#FILUSDT ⭐Shooting Star#ZENUSDT ⭐Shooting Star#TRXUSDT 🚀Marubozu Bullish#USD1USDT