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

Резултати

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

Пребарај: #alpha

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

@proanalysistrader · Post #28355 · 24.12.2024 г., 13:46

#ALPHA/USDT analysis : #ALPHA is currently in an uptrend, forming higher highs (HHs) and higher lows (HLs). The price has retraced to a support zone, and a bounce back is anticipated, with expectations to test previous highs. TF : 1D Entry : $0.0870 Target : $0.1340 SL : $0.0674

Hashtags

Pro Analysis

@proanalysistrader · Post #27943 · 18.09.2024 г., 14:26

#ALPHA/USDT analysis : #ALPHA is presently in a downtrend, trading below the 200 EMA. The price is establishing a pattern of lower lows and lower highs. Currently, it encounters resistance near the 200 EMA, indicating a possible continuation of its bearish trend and a retest of previous lows. TF : 4h Entry : $0.0558 Target : $0.0520 SL : $0.0584

Hashtags

American Crypto©

@americancryptotrading · Post #27104 · 01.01.2025 г., 17:54

🇺🇸#ALPHA/USDT is heading towards the descendingtriangle pattern on the weekly timeframe👀 Breakout - Retest - Go🐃 American Crypto©

Hashtags

Coinlegs Cryptocurrency Signals

@coinlegs · Post #9322 · 05.11.2023 г., 13:44

Custom Signal: Combination of 👉 Double Bottom 👉 Bollinger Breakout 👉 Trend Line Breakout We expect the price goes up after double bottom but we can’t trade by using only double bottom pattern. We look for another bullish moves like bollinger or trend line breakout. What if double bottom, Trend Line Breakout and Bollinger Breakout occur for any asset and it’s price hasn’t risen yet Bingo !! #ALPHA did 15% in just 3 hours 👌 Just check the chart, let’s create custom signal

Hashtags

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