@digitalgentop · Post #41 · 21.05.2024 г., 21:22
💰📊In the past 24 hours, Ethereum whales have purchased more than 110,000 ETH valued at $341 million!💵😮 #Cryptoenthusiast #Cryptocurrencies #Cryptowallet
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
Пребарај: #cryptoenthusiast
@digitalgentop · Post #41 · 21.05.2024 г., 21:22
💰📊In the past 24 hours, Ethereum whales have purchased more than 110,000 ETH valued at $341 million!💵😮 #Cryptoenthusiast #Cryptocurrencies #Cryptowallet
@digitalgentop · Post #11 · 21.05.2024 г., 17:43
💰📊In the past 24 hours, Ethereum whales have purchased more than 110,000 ETH valued at $341 million!💵😮 #Cryptoenthusiast #Cryptocurrencies #Cryptowallet
@digitalgentop · Post #241 · 06.06.2024 г., 08:02
⚡️Main news: 🔗Wallet on Telegram enforces new KYC rules, switches provider 🟢 PEPE whale up nearly $5M on investment within a month 💵Next $1 trillion company will be DePIN 📌 Alex Labs rolls out post-exploit recovery plan 💰Bitcoin in 42-day ‘boredom zone’ — traders debate next move #Cryptoanalysis #Cryptoenthusiast #Cryptocurrencies #Cryptowallet
@digitalgentop · Post #240 · 06.06.2024 г., 02:57
❗️Donald Trump found guilty in landmark New York hush-money case 🇺🇸 #Cryptoanalysis #Cryptoenthusiast #Cryptocurrencies #Cryptowallet
@digitalgentop · Post #230 · 04.06.2024 г., 03:02
💵Gemini returns $2.18B to Earn users following 18-month withdrawal freeze ⌛ #Cryptoanalysis #Cryptoenthusiast #Cryptocurrencies #Cryptowallet
@digitalgentop · Post #224 · 02.06.2024 г., 16:01
☄️ZKasino gives investors 72-hour window to get back deposited ETH 💵ZKasino denied it tried to make off with $33 million of investor funds in April and has now opened up a short refund window. #Cryptoanalysis #Cryptoenthusiast #Cryptocurrencies #Cryptowallet
@digitalgentop · Post #213 · 31.05.2024 г., 16:01
🔖Shiba Inu Super Diamond Trader Liquidates Holdings, Followed By A Secret Message 📣 #Cryptoenthusiast #Cryptocurrencies #Cryptowallet #Cryptoeducation #Bitcoinnews