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

Резултати

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

Пребарај: #stoploss

当前筛选 #stoploss清除筛选
Crypto M - Crypto News

@CryptoM · Post #65211 · 12.04.2026 г., 02:14

🚀 Crypto Whale Adjusts Stop-Loss to Secure Profits On April 12, a prominent crypto trader known as 'Set 10 Big Goals' (@Jason60704294) announced adjustments to their stop-loss positions to prevent targeted liquidation. According to BlockBeats, the trader has already secured profits from their current short positions. Previously, it was reported that the trader held a short position of 2,567.49 BTC with an entry price of $71,554.61, and a short position of 38,465.22 ETH with an entry price of $2,248.74. #Crypto#Bitcoin#Ethereum#Trading#StopLoss#ProfitTaking#CryptoWhale#BTC#ETH

Crypto M - Crypto News

@CryptoM · Post #65210 · 12.04.2026 г., 02:09

🚀 Analyst Discusses Stop-Loss Adjustment Strategy An analyst, @ai_9684xtpa, posted on X about the rationale behind adjusting a stop-loss point to $73,500. The adjustment was made to prevent precise liquidation, and the analyst noted that the price nearly reached this adjusted level. #StopLoss#TradingStrategy#MarketAnalysis#RiskManagement#PriceAdjustment#Investing

Crypto M - Crypto News

@CryptoM · Post #64987 · 10.04.2026 г., 12:57

🚀 Major BTC Long Position Liquidated on Hyperliquid Platform In the last 10 minutes, a significant BTC long position was liquidated on Hyperliquid, according to ChainCatcher. The position, held by the entity identified as 0x1e9, was closed at a price of $71,463, resulting in a substantial sell order. The position was initially opened today at 6 a.m. UTC+8, when BTC was trading above $72,000. It involved 247 BTC, equivalent to approximately $17.65 million. As the price declined, the holder opted for a rapid stop-loss exit, incurring a loss of about $180,000. #BTC#longposition#liquidation#Hyperliquid#ChainCatcher#cryptocurrency#BTCprice#stoploss#cryptotrading#loss