TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #146 · 16 сеп.

Функция sub в regex может принимать функцию в качестве аргумента repl. 📄 Из документации: If repl is a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. То есть для каждого совпадения будет вызвана функция для вычисления замены вместо замены на одну и ту же строку для всех совпадений. Иными словами, для замены разных совпадений на разные строки не потребуется запускать re.sub() много раз для каждой строки замены. Достаточно определить функцию, которая вернёт строку для каждого из совпадений. Описание слишком запутанное🤔, давайте лучше рассмотрим на простом примере: Создаем карту замены. То есть какие строки на какие требуется менять. remap = { 'раз': '1', 'два': '2', 'три': '3', 'четыре': '4', 'пять': '5', } Пишем функцию поиска строки для замены. Единственным аргументом будет объект re.Match. Используя данные этого объекта мы вычисляем замену on-the-fly! def get_str(match: re.Match): word = match.group(1) return remap.get(word.lower()) or word Пример текста. text = '''Раз Два Три Четыре Пять Вместе будем мы считать Пять Четыре Три Два Раз Мы считать научим вас ''' Теперь запускаем re.sub и вместо строки замены (repl) подаём имя функции. (Данный паттерн ищет отдельные слова в тексте) >>> print(re.sub(r'(\w+)', get_str, text)) 1 2 3 4 5 Вместе будем мы считать 5 4 3 2 1 Мы считать научим вас Думаю, достаточно наглядно 🤓 #libs#regex

Hashtags

Резултати

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

Пребарај: #university

当前筛选 #university清除筛选
Kursiv Uzbekistan (Eng)

@kursivuzeng · Post #2653 · 23.02.2026 г., 18:25

🇮🇷 Breaking: University protests flare up across Iran New student protests erupted at major Iranian universities as the new term began, with demonstrators honouring victims of last month’s deadly crackdown. Clashes were reported in Tehran, with chants targeting Supreme Leader Ali Khamenei and reviving the “Woman, Life, Freedom” movement. The unrest comes amid rising geopolitical tensions, as the U.S. boosts its regional military presence while nuclear talks with Tehran remain unresolved. #News#Iran#University

✨Jast mi🌷🇫🇷

@jastm1 · Post #5445 · 24.08.2025 г., 09:24

「💻」#university#studying_tips new semester, better me 📚🦪. Yesterday I did a lot of stuff including unpacking and setting up my room for the semester. Of course I will redecorate it, however I shouldn’t forget that this room is for only one semester ✨ Inshallah will go to study away 😻 ~🐈~ ↬@jastm1🌊

✨Jast mi🌷🇫🇷

@jastm1 · Post #5416 · 16.08.2025 г., 17:14

「💻」#university#studying_tips ❤️Some college x School inspo ✨A new chapter is here!✨ Are you ready for school/college? ✨ This is the perfect time to set new ambitions and new goals. A chance to start fresh, grow, and chase the best version of yourself. 🌱 Don’t be shy, step forward with confidence, give it your best, and make this year unforgettable.💗🫶 ~🐈~ ↬@jastm1🌊

✨Jast mi🌷🇫🇷

@jastm1 · Post #5406 · 15.08.2025 г., 05:59

「💻」#university#studying_tips Checklist of things to pack for UNIVERSITY🥳! Most of you might be overwhelmed with the amount of things to do, but don't worry you've got this 💪. Save not to loose! ~🐈~ ↬@jastm1🌊

djangoproject

@djangoproject · Post #194 · 31.10.2016 г., 12:39

https://www.coursera.org/specializations/data-science-python?utm_medium=email&utm_source=marketing&utm_campaign=2QBGEJZREeajEnVsu251ig The 5 courses in this #University of #Michigan specialization introduce learners to data science through the python programming language. This skills-based specialization is intended for learners who have basic a python or programming background, and want to apply statistical, machine learning, information visualization, and text analysis techniques to gain new insight into their data. Introduction to Data Science with Python (course 1), Applied Plotting, Charting & Data Representation in Python (course 2), and Applied Machine Learning in Python (course 3) should be taken in order and prior to any other course in the specialization. After completing those, courses 4 and 5 can be taken in any order. All 5 are required to earn a certificate.

一个半月没上tg了,创造了最长时间不上tg的记录,高考前也没有这样过。大学报道前的这段暑假以及报道后的一段时间里,现实生活过于充实以至于忘了上tg。某一天很忙没来,第二天也很忙没来,第三天休息一下也没来……一个半月前脱离tg的过程就是这样开始的。 开学前到处玩到处吃喝,以迎接将到来的封闭管理大学生活。开学后手机里塞满了各种群,各种表格及文档,各种通知和须知,还没开课就忙得团团转。很多需要的物品是之前没料到的,开学后陆续订购,到现在还没有购齐,每天都会出现一些新的需求。 有时间再来续写 #Diary 日记 #Life 生活 #University 大学

🇰🇷Janubiy Koreya ta’lim tashkilotlari bilan hamkorlik aloqalari mustahkamlanmoqda 🇺🇿Batafsil ___ Strengthening cooperation with South Korean educational organizations 🇬🇧Eng ___ Укрепление сотрудничества с Южно-Корейскими образовательными организациями 🇷🇺Ru #GraduateSchool#Soonchunhyang#University#Cooperation Web-site | Telegram | Facebook | Instagram

Handong Global universiteti bilan hamkorlikni yangi bosqichlari 🇺🇿Batafsil ___ New Stages of Collaboration with Handong Global University 🇬🇧Eng ___ Новые этапы сотрудничества с Глобальным университетом Хандонг 🇷🇺Ru #GraduateSchool#Handong#Collaboration#University Web-site | Telegram | Facebook | Instagram

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