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 слични објави

Пребарај: #betatest

当前筛选 #betatest清除筛选
SingSing Announcement

@singsingchannel · Post #1123 · 20.12.2024 г., 10:46

🌸Beta Test Closing Announcement🌸 The Mystic Garden Beta Test has officially ended! 💎 Thank you to all the players who participated and helped shape the game. 🌱 🏆Winners List and rewards will be announced soon. Stay tuned for updates! 🚀 #MysticGarden#BetaTest#Web3Gaming

SingSing Announcement

@singsingchannel · Post #1107 · 14.12.2024 г., 10:27

🚨 Mystic Garden Beta Test Reward Alert! 🚨 🌿 Dive into the enchanting world of Mystic Garden and claim your share of $500 AURA in rewards! 🌟 🎮 Beta Testers Wanted 💎 Exclusive prizes await 🌌 ⏳ Don't miss the magic—beta testing opens soon! #MysticGarden#BetaTest#Rewards

SingSing Announcement

@singsingchannel · Post #1111 · 16.12.2024 г., 04:36

🌟How to Earn Crystals and Share $500 AURA in Mystic Garden?🌟 Beta Testers, this is your moment to shine! 🚀 🔹How to Share $500 AURA • Harvest Crystals and sell them to earn GOLD. • Rewards depend on the percentage of GOLD you contribute to the total GOLD from all players. 🏆 🔹Crystal Breakdown: 👉Tier 1 Elements🌱💧🔥🌬 • Earth, Water, Fire, Air ⏳ Growth Time: 1h - 1.5h 💎 Yield: 5-11 Crystals 🎁 Bonus Drop: 15-20% chance 👉Tier 2 Elements🪨⚙️🏖⚡️ • Combine Tier 1 to unlock: Mud, Sand, Metal, Steam, Mist, Lightning ⏳ Growth Time: 2.5h - 8h 💎 Yield: 7-11 Crystals 👉Tier 3 Elements Coming Soon🌌 • Unlock combos like Light ☀️, Dark 🌑, Twilight! 🔔Leaderboard Mechanics: • GOLD from selling Crystals determines your rank. • Rewards are based on your GOLD percentage compared to all players. 🏅 Note: The parameters are not fixed, they will still be adjusted to always ensure suitability for the game! The garden awaits. Grow and compete! 🌸 #MysticGarden#BetaTest#EarnRewards#CrystalLeaderboard

Walken.io - Announcement

@walken_channel · Post #7 · 23.11.2021 г., 14:38

📢 BETA TEST is coming soon! We know you're itching to have a go and acquire your first CAThlete 🐷 Great news: gameplay development is progressing, and we're preparing a 💥playable beta💥! We are grateful for your patience and will announce the start of beta testing in advance⏰ Stay tuned and don't miss out on the fun! 🐦 twitter: https://twitter.com/walken_io 🧨 medium https://medium.com/@walken.io 🕹️ discord https://discord.gg/QJDnFt6S4J #nft#walken#walkandearn#NFTGaming#blockchaingame#betatest#betatester