@keyframepro · Post #38 · 10.06.2025 г., 12:45
Kasperskiy - Threat management and defense #3d#cg#commercial#coproduction#it#kasperskiy
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
Пребарај: #kasperskiy
@keyframepro · Post #38 · 10.06.2025 г., 12:45
Kasperskiy - Threat management and defense #3d#cg#commercial#coproduction#it#kasperskiy
@keyframepro · Post #21 · 10.06.2025 г., 11:55
Kasperskiy - Endpoint Security #3d#cg#commercial#coproduction#it#kasperskiy
@keyframepro · Post #19 · 10.06.2025 г., 11:55
Kasperskiy - Threat Intelligence #3d#cg#commercial#coproduction#it#kasperskiy
@keyframepro · Post #18 · 10.06.2025 г., 11:54
Kasperskiy - GREAT #3d#cg#commercial#coproduction#it#kasperskiy
@keyframepro · Post #22 · 10.06.2025 г., 11:57
Kasperskiy - Cloud Security #3d#2d#cg#commercial#coproduction#it#kasperskiy
@keyframepro · Post #23 · 10.06.2025 г., 11:58
Kasperskiy - Internet of things #2d#cg#commercial#coproduction#humor#it#kasperskiy
@keyframepro · Post #20 · 10.06.2025 г., 11:55
Kasperskiy - Fraud Prevention Series #3d#2d#cg#commercial#coproduction#humor#it#kasperskiy
@keyframepro · Post #35 · 10.06.2025 г., 12:26
👓 Привет! Hello! Меня зовут Максим Слюсарев. My name is Maxim Sliussarev. 😠Я режиссёр, продюсер и сценарист. А это мой креативный бутик Keyframe Production. Представленные ролики все придуманы мною и реализованы либо мной лично, либо в сотрудничестве с другими студиями. На всех из них я выступал сценаристом и режиссёром, а на многих продюсером, монтажером и даже художником графики. За годы работы я стал обладателем множества призов, как за музыкальные клипы, так и за рекламу и кино, а в 25 году и за ии-кино. 🐈⬛ I’m a director, producer, and screenwriter. This is my creative boutique — Keyframe Production. All the featured videos were conceived by me and brought to life either personally or in collaboration with other studios. I worked as the screenwriter and director on all of them, and on many — also as producer, editor, and even graphic artist. Over the years, I have won many prizes, both for music videos, as well as for advertising and cinema, and in 2025 for AI-films. 😂Пишите в телегу @maximixam или [email protected] 😱Contact me via telegram @maximixam or [email protected] По хештегам вы можете найти работы во всех сферах видеопроизводства от съемки до ии: You can find projects from all areas of video production by following the hashtags: #ai#bank#cars#cg#commercial#documentary#deepfake#drama#exhibition#fashion#film#humor#interactive#it#kasperskiy#kids#mecha#microsoft#musicvideo#social#shortfilm#show#sounddesing#showreel#space#sport#tvseries#videoproduction#2d#3d