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

Резултати

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

Пребарај: #michigan

当前筛选 #michigan清除筛选
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.

American Оbserver

@american_observer · Post #4917 · 21.01.2026 г., 15:59

The most massive accident since the beginning of the year in the United States involving more than 100 cars in Michigan. #massive#accident#cars#michigan 📱American Оbserver - Stay up to date on all important events 🇺🇸

Pensiero Verticale

@verticale_blog · Post #574 · 29.09.2025 г., 17:57

Quando la vi*lenza diventa strumento di politica estera, prima o poi ritorna a bussare alle porte di casa. Le gu*rre combattute lontano, la retorica della libertà usata come maschera di interessi economici, l’addestramento alla disumanizzazione: tutto ciò si traduce oggi in una società che implode sotto il peso delle proprie stesse contraddizioni. La lezione è chiara: ciò che un impero esporta, inevitabilmente lo eredita. #guerra#michigan#detroit#attualita#news#oggi#america

r_iww

@r_iww · Post #4865 · 21.02.2026 г., 07:35

Chipotle Michigan Unionization with Teamsters (3 years & 6 months on) August 2022, workers at a Chipotle in Lansing, Michigan, voted 11-3 to unionize, becoming the first and only employees at the chain to ever win union recognition. Three years later, they still don’t have a contract. After years of bargaining, the Chipotle corporation and Teamsters have indefinitely paused negotiations, and workers no longer anticipate a collective bargaining agreement at their store. https://jacobin.com/2026/02/chipotle-unionization-michigan-teamsters-organizing \#Chipotle#LabourMovement#MIchigan#Organize#Teamsters#Unions https://redd.it/1r8f9ni @r_iww

Venture Village Wall 🦄

@venturevillagewall · Post #4148 · 14.02.2025 г., 10:00

New Developments in Tech and Crypto News • Russian electronic voting to become mandatory at all levels, limiting paper ballots. More info here. • VK acquires 25% of office software developer R7 for approx. 2.5–3.5 billion rubles. Read more here. • Russia sees illegitimate web traffic rise to 12%, with half from botnets. More details here. • TikTok returns to U.S. app stores after a 25-day hiatus, facing a 50-day deadline for ByteDance to divest its U.S. operations. Update here. • Apple plans to integrate AI functions in iPhones in China by May, using Alibaba's models for compliance. More info here. • Avride begins testing delivery robots with Uber Eats in Jersey City. Full update here. • Michigan lawmakers propose investing 10% of state funds in crypto. Details here. • Ethereum developers release Pectra client software before April mainnet upgrade. Check here. • Aave records its highest revenue month ever in January. See more here. • Doodles NFT project announces DOOD token on Solana, issuing 10 billion tokens, 68% for the community. Update here. • BNB Chain faces user influx challenges after CZ's controversial comments, causing a 10% drop in BNB price. More info here. • President of El Salvador, Bukele, meets with Michael Saylor to discuss Bitcoin. More details here. #E-voting #Russia#VK#R7#WebTraffic#TikTok#ByteDance#Apple#AI#China#Avride#UberEats#Crypto#Michigan#Ethereum#Aave#NFT#Doodles#BNB#ElSalvador#Bitcoin