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

Резултати

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

Пребарај: #tomnumbers

当前筛选 #tomnumbers清除筛选
JenniferMac

@JenniferMac · Post #288 · 13.04.2023 г., 16:12

https://youtu.be/Qhb8D4iyRZI👈🏻📺 FREE to watch on YOUTUBE today TRUMP BISCUIT, Dogs, clones, James Bond & more…. the latest with JUAN O SAVIN & #TomNUMBERS 📯🍪🐕🧬🦠💉🎬😉

Hashtags

JenniferMac

@JenniferMac · Post #283 · 06.04.2023 г., 15:33

https://youtu.be/Eab0Fh-Yadg Free to view on YOUTUBE today JUAN O SAVIN & #TomNUMBERS Discuss The TRUMP Arrest, CIA, playboy, Christ’s delayed reaction to raising Lazarus from the Dead… Judus & The Last Supper … and much much more 🎺🎬📰

Hashtags

JenniferMac

@JenniferMac · Post #246 · 06.02.2023 г., 15:49

https://youtu.be/bsM5CDhfPTg👈🏻🎈🎬 JUAN O SAVIN #TomNUMBERS & THE BALLOON 🎈 Juan goes into detail on the chinese balloon, ramifications & what we might expect moving forward & some of the hidden gematria number gems to go with it… A must watch show 🎬🤠🎈👍🏼

Hashtags

JenniferMac

@JenniferMac · Post #226 · 13.01.2023 г., 21:16

https://youtu.be/-Wz0GGixbdQ👈🏻📺 The New FULL unreleased episode with JUAN O SAVIN, #TomNUMBERS & ANA MARINS - full update on Brasil, Brunson Case, Kevin McCarthy & much much more 👍🏼😉🤠🇧🇷🇺🇸🇬🇧

Hashtags

JenniferMac

@JenniferMac · Post #224 · 11.01.2023 г., 17:44

https://youtu.be/-UdkPAxWshI👈🏻📺🕊🎬 JUAN O SAVIN “HOW TO PERFORM MIRACLES IN THE MATRIX” with #TomNumbers & Ana Marins This is a mind blowing reveal from #JuanOSavin How we as the children of Adam can perform miracles - and are commanded to do so, for the benefit of all mankind 19.47 / 19.5 ⛰🗻🌋 The Power Number MOVE THE MOUNTAIN = 195 ⭐️⭐️⭐️⭐️⭐️

JenniferMac

@JenniferMac · Post #208 · 22.12.2022 г., 17:07

https://youtu.be/VIuJUWftfO4👈🏻📺 #JuanOSavin the history of CHRISTMAS with #TomNumbers & Rachel WriteSide Blonde The KING OF MISRULE , Saturn 🪐, The B-Ring of Saturn what was it a weapon ? Destroyer of Worlds, StarWars, Twitter, Donald #Trump Junior, Elon, The Statue of Liberty 🗽 … and much much more… Merry Christmas everyone 🎄🎺🎁🎅🏼

JenniferMac

@JenniferMac · Post #234 · 23.01.2023 г., 18:26

https://youtu.be/vfve6XBMQag👈🏻📺🌚 JUAN O SAVIN & #TomNUMBERS MOON: Is The Forbidden Planet 🌝🌑🛸 Juan describes in detail the history of the Earth, how Earth use to be under a compressed hydrogen canopy… and the real nature of what the moon really is Think Forbidden Planet, Planet Of The Apes 🗽🐵🦍, Starwars, Back To The Future, Interstellar & Space Odyssey 2001… BEST SHOW so far I’ve done with #JuanOSavin🕊 ENJOY #PsychClub#TheTomNumbersShow Starts at 5.45pm U.K. GMT / 9.45am PST 👍🏼📺🤠

JenniferMac

@JenniferMac · Post #199 · 16.12.2022 г., 06:02

https://youtu.be/DFiIzzL50DU👈🏻🃏📺🟦🟥🟨 #JuanOSavin#TomNumbers Rachel WriteSideBlonde & Jetson White discuss THE SuperHero TRUMPCARD NFT announcement TRUMPCARDS , JOKER CARDS & WILDCARDS 🃏🃏🃏 The Brunson Supreme Court Nikola Telsa being a ladies man 😉🕊, the other physics, Meaning of Christmas 🎄 And much much more … #TheTomNumbersShow#TopOfYourGame#PsychClub#Gematria

JenniferMac

@JenniferMac · Post #221 · 07.01.2023 г., 17:56

https://youtu.be/rvsW1MqUyzo👈🏻📺🇿🇦🇺🇸🕊🎺 LARA LOGAN with #TomNUMBERS Lara Logan is a strong FEMALE warrior of the truth, investigative journalist, war zone news anchor & former FOX TV host 🦊 In this NEVER BEFORE released interview SHE shares the connection between ABRAHAM LINCOLN, JAMES BOND & Q… Benghazi, and the SECRET MILITARY super fast rescue teams deployed in times of war 🛸 Her message is to NEVER SURRENDER !!! #TheTomNumbersShow#TopOfYourGame#PsychClub#Gematria#LaraLogan⭐️⭐️⭐️⭐️⭐️

JenniferMac

@JenniferMac · Post #177 · 26.11.2022 г., 16:04

https://youtu.be/7HVZj1TRfHs👈🏻📺⚖️ #JuanOSavin reveals SCOTUS case Brunson v Adams was moved to the NATIONS EMERGENCIES Docket today! SCOTUS front lined it ! This could bring down the Deep State house of cards imminently 🃏 #Trump The MAGADOR 🐃🟥📯 Must watch episode with Juan O Savin, #TomNumbers & WriteSideBlonde #PsychClub#TopOfYourGame#TheTomNumbersShow#Gematria The White Dove Society 🕊

JenniferMac

@JenniferMac · Post #419 · 30.12.2023 г., 18:47

JUAN O SAVIN talks CURRENCIES, Rv, Nesara, Gold & Silver ⭐️⭐️⭐️⭐️ Show starts today 4.45pm UK/ 11.45am EST/ 8.45am PST 🎬🟨⬜️🤠👍🏼https://youtu.be/G5CLmCNPvtw👆🏼📺🎉 JUAN O SAVIN talks CURRENCIES & 2024 with TOM NUMBERS… Kim Clement, The Rv, Nesara, Gesara, Two Presidents, Tribunals, Aliens, behind the scenes, Roswell, 19.47, Silver, Gold, Nixon, other physics & more.. this is a bumper early NEW YEARS EVE show https://youtu.be/G5CLmCNPvtw👈🏼📺🤠 watch here on YouTube & subscribe to notifications 👆🏼🔔🔔🔢 RETWEET 🔂 #JuanOSavin#Currency#TomNumbers#Gematria#Silver#Gold

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