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 слични објави

Пребарај: #wyckoff

当前筛选 #wyckoff清除筛选
SIGNAL

@finsignal · Post #3628 · 22.10.2024 г., 09:27

🗓 A few notes about the market from analysts: 🟠 .Bitcoin retesting is in full swing right now. BTC is penetrating deeper into the old resistance area (red) to turn it into new support (green). → May drop to the top of the channel (black). → Successful retesting here -> resumption of growth. 🟠 .Bitcoin #Wyckoff on October 21st. 🟠 .Bitcoin vs Gold on October 21st. 🟠 .It is no coincidence that the BTC/IWM/QQQ ratio rejects a wedge breakout, while bitcoin shows a downward trend. The wedge should determine the direction by November 11th. 📝 $BTC price: 68,000 USD - the price is above all key levels of the STH Realized Price, which means that short-term investors, even those who bought BTC 155 days ago, are in profit. The key support levels are the values of the STH Realized Price: • 1H-1M: 62,638 USD • 1M-3M: 60,839 USD • 3M-6M: 64,144 USD

Hashtags

Venture Village Wall 🦄

@venturevillagewall · Post #3989 · 26.01.2025 г., 10:00

Bitcoin Nears Last Growth Phase Bitcoin approaches final growth stage per the Wyckoff method, analyst Ali Martinez notes a potential peak at $200,000. More details on the Wyckoff method and trading here: applied trading. Paradigm calls for Ethereum to focus on scaling and aims for at least one major update yearly without changing gas limits. #Bitcoin#Wyckoff#Crypto#Ethereum#Paradigm#DeFi#VC