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

Резултати

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

Пребарај: #cryptoexchanges

当前筛选 #cryptoexchanges清除筛选
Crypto M - Crypto News

@CryptoM · Post #64868 · 10.04.2026 г., 05:49

🚀 New Altcoin Listings Show Decline in Value Over Time According to NS3.AI, CoinGecko's recent analysis reveals that approximately 90% of newly listed altcoins on the top 12 centralized exchanges have fallen below their initial listing price within a year. The report highlights that only about 32% of these new listings experienced immediate gains upon going live. Furthermore, by the end of the 12-month period, fewer than 10% of tokens listed on major exchanges maintained a value above their debut price. #Altcoins#Cryptocurrency#CoinGecko#CryptoMarket#TokenValue#NewListings#CryptoExchanges#MarketDecline#NS3AI#CryptocurrencyTrends#Investment

Venture Village Wall 🦄

@venturevillagewall · Post #4338 · 08.03.2025 г., 10:00

Utah Establishes First Bitcoin Reserve 🔵 Utah becomes the first U.S. state to create a strategic Bitcoin reserve. This initiative aims to enhance regional economic stability and protect state assets from inflation and market fluctuations. Read more here. 🔴 In contrast, Russia remains hesitant to include Bitcoin in its National Wealth Fund, citing its volatility. Nevertheless, the Deputy Minister of Finance indicated a review of the strategy may occur if reserves reach a certain level, potentially incorporating higher-yield assets like crypto in the future. Read more here. ⭐️ Gemini cryptocurrency exchange confidentially filed for an IPO, partnering with Goldman Sachs and Citigroup, potentially eyeing a market entry in 2025. More details available here. #Bitcoin#Utah#Crypto#Russia#IPO#Gemini#Finance#Market#Investment#ETF#Volatility#Assets#Economy#Regulation#Wealth#Liquidity#Traders#CryptoExchanges#BNB#BSC#VC