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

Резултати

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

Пребарај: #part3

当前筛选 #part3清除筛选
Toward Discovering English

@TowardDiscoveringEnglish · Post #351 · 25.05.2021 г., 09:24

​⚜️ CORONA VOCAB 2019-20 ⚜️ 🧪 English grammar & Vocab 🌡 #Part3 🦠Containment area ✔️ a geographical zone with limited access in or out in an effort to contain an outbreak. 🦠Coronavirus ✔️ a family of viruses that include SARS (severe acute respiratory syndrome) and MERS (Middle East respiratory syndrome) as well as other respiratory illnesses. A coronaviruses, also known as a CoV, is typically spread between animals and humans—an event known as zoonotic transfer—and they are named for the term “corona”—Latin for crown—which refers to the shape of the virus when observed microscopically. 🦠COVID-19 ✔️COVID-19 stands for novel coronavirus disease 2019, which refers to the year of its initial detection. COVID-19 is the illness related to the current pandemic; the illness is caused by the virus SARS-CoV-2 (severe acute respiratory syndrome coronavirus 2). 🦠Epidemic ✔️a widespread occurrence of an infectious disease in a community or geographic area. 🦋@TowardDiscoveringEnglish🦋

Hashtags

Journey to Fluency

@fluencyinenglish · Post #7900 · 03.10.2025 г., 13:15

در IELTS Speaking، خصوصاً Part 3، نمره شما بر اساس مهارت زبانی (Fluency & Coherence, Lexical Resource, Grammatical Range & Accuracy, Pronunciation) داده می‌شود، نه میزان اطلاعات عمومی یا صحت factual. ✅ راهکارهای عملی 1. از تردید کردن نترسید و صادق باشید جملاتی مثل: “I’m not an expert in this field, but I think…” “I don’t know much about this, although it seems that…” به شما اجازه می‌دهد بدون توقف ادامه دهید. 2. استفاده از speculation یا حدس منطقی وقتی نمی‌دانید، می‌توانید با حدس منطقی نظر بدهید: “It might be because…” “Perhaps this will lead to…” 3. مثال شخصی یا تجربه روزمره بیاورید “From my own experience…” یا “In my city/school…” حتی اگر اطلاعات عمومی کم باشد، مثال شخصی به طولانی‌تر شدن پاسخ و انسجام کمک می‌کند. 4. تمرکز روی انسجام و روانی صحبت از ضمیرها و ربط‌دهنده‌ها (this, that, these, however, on the other hand) استفاده کنید تا جمله‌ها به هم وصل شوند. 5. استفاده از واژگان پیشرفته و ساختارهای گرامری متنوع به جای تکیه روی اطلاعات، از واژگان دقیق و اصطلاحات متداول آیلتس استفاده کنید: “plays a pivotal role” “poses a significant challenge” “from my perspective” 🔹 نمونه پاسخ با speculation Q: Do you think governments should invest more in renewable energy? > “I’m not fully aware of all the policies, but I think governments should invest more in renewable energy. It might help reduce pollution and create new jobs. For example, building more solar farms could provide electricity for many households. Although I don’t know all the details, it seems like a positive step for the future.” #IELTS#IELTSSpeaking#SpeakingTips#Hedging#Speculation#Fluency#Coherence#LexicalResource#Band8#آیلتس#Part3#EnglishSpeaking#LanguageTips#AdvancedEnglish#Pronunciation