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

Резултати

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

Пребарај: #cryptotrading

当前筛选 #cryptotrading清除筛选

Live Crypto News Today — Bitcoin, Ethereum & Altcoins (February 16, 2026) https://www.fxpremiere.com/live-crypto-news-today-bitcoin-ethereum-altcoins-february-16-2026/#crypto#cryptocurrency#cryptonews#cryptotrading FxPremiere Telegram Alerts

🟥 🟥 🟥GOYIM COIN – SOLANA GEM ALERT 🚀 📈 Strong Pump Ongoing | Heavy Volume Flow 🚀 Early buyers are already winning — next leg loading… 🔹 Chain: Solana 📈 Live on DexScreener: https://dexscreener.com/solana/ASCSDmpkbXDNRiPRKGAPiLU4Kukc6P8vgNBtNhGw3Hnf ✔️ Contract: 9S8edqWxoWz5LYLnxWUmWBJnePg35WfdYQp7HQkUpump 🐋Strong buying pressure • Healthy volume inflow • Meme narrative + active community 🚀 Official Links: 🐦Twitter (X): https://x.com/goyimcoinsol 🌎 Website: https://goyim.life/ #Solana#LowCap#CryptoTrading

Propheta Indicator Signals

@propheta_indicator · Post #23074 · 19.11.2025 г., 17:57

👆 Propheta living up to its name yet again 🔮 Reached 9th TP in the VIP PRO channel! That's why we call it the "Money Printer" 💴💷💵ACCESS TO MANUAL TRADING for 70usdt/month 👉 Looking at those reports and can't believe what you're seing? Go to our reports channel and audit us! @propheta_reports Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #cryptotrading#autotrading#cryptomarket

Propheta Indicator Signals

@propheta_indicator · Post #22867 · 07.10.2025 г., 12:13

Reached 9th TP in the VIP HTL channel! Easy $207 with a 5% entry and a $1000 deposit! VIPs getting filthy rich by the day ☺️🤑🤑ACCESS TO MANUAL TRADING for 70usdt/month 👉 Join us and earn big! Start here: t.me/ProphetaAdmin_bot Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #cryptobot#cryptotrading#eth

123•••10•••202122
ПретходнаСтраница 1 од 22Следна