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

Резултати

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

Пребарај: #distribution

当前筛选 #distribution清除筛选
Amazing Geography 🌍

@amazingeo · Post #383 · 17.10.2025 г., 15:31

🌍 Just 2% of the world’s population lives in countries with fewer than one million people, while over half reside in just seven nations, highlighting an immense population imbalance. ✨ #population⚡#demography⚡#distribution⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #35 · 11.08.2025 г., 03:12

🌍 More than 90% of the world's population lives in the Northern Hemisphere, even though the Southern Hemisphere covers about 40% of Earth's land. The balance of people is strikingly uneven. ✨ #population⚡#hemispheres⚡#distribution⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Как устроен Balton Trading Asia: взгляд изнутри Представители Balton Trading Asia, одного из ведущих игроков рынка FMCG-дистрибуции в Узбекистане показали и рассказали о своём новом складе класса "А+", а также обсудили: ✔️ Построение эффективной логистики; ✔️ Что такое 3PL; ✔️ Что такое дистрибуция; ✔️ Как современные системы WMS и TMS оптимизируют ключевые процессы А также рассказали о том, для кого важны услуги логистики и хранения Все это в новом ролике на gazeta.uz #LOGISTICS#BALTONTRADINGASIA#UZBEKISTAN#DISTRIBUTION#3PL#WAREHOUSE

Venture Village Wall 🦄

@venturevillagewall · Post #3848 · 11.01.2025 г., 13:00

200M for Email Simplification App! In 2013, a startup created a user-friendly email app to combine personal and work emails, reducing clicks to complete tasks. Microsoft acquired the app for $200 million after 18 months. Initially, it reached 3 million users at launch, soaring to hundreds of millions three years later. The founder emphasized a goal to simplify, not reinvent, email—echoing Dropbox's approach of enhancing existing solutions. Glassnode notes a 49.6% increase in new investors controlling bitcoin supply, with long-term holders redistributing assets, though it's not seen as a bearish signal. Insights from tech analyst Ali Martinez suggest declining hype around AI agents, affecting specific token prices. Polymarket users estimate a 12% chance the US government will sell seized BTC before Trump's inauguration, with $6.5 billion at stake. #Email#Microsoft#Startup#Acquisition#Usability#Glassnode#Bitcoin#Investors#Crypto#AI#MarketTrends#Polymarket#BTC#Trading#Innovation#TechNews#VC#Fundraising#TechAnalytics#Distribution

Venture Village Wall 🦄

@venturevillagewall · Post #3857 · 12.01.2025 г., 16:00

FTX Announces Preliminary Fund Distribution Schedule 🔵 FTX reveals a preliminary payment distribution schedule for creditors. 🔵 Claims under $50k total $1.2 billion. 🔴 By January 20: Preliminary claims must be met. 🔴February 25 - March 4: Expected period for fund distribution begins. 🤔 Will this bring additional liquidity to the market? Read more #FTX#Crypto#Market#Liquidity#Payments#Claims#Finance#Investments#Bitcoin#News#Updates#Distribution#Schedule#CryptoTwitter#Investors#Creditors#Funds#Return#January#February#March