@phthemes · Post #325 · 12.06.2021 г., 02:41
ㅤ TEAM 7 FROM NARUTO 🝐🝐🝐🝐🝐🝐🝐🝐🝐🝐 #dark#glassy#anime#blue ㅤ · Platforms: Android, iOS and TDesktop · Theme by@phthemes · Wallpaper by @bobohugifs ㅤ
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
Пребарај: #glassy
@phthemes · Post #325 · 12.06.2021 г., 02:41
ㅤ TEAM 7 FROM NARUTO 🝐🝐🝐🝐🝐🝐🝐🝐🝐🝐 #dark#glassy#anime#blue ㅤ · Platforms: Android, iOS and TDesktop · Theme by@phthemes · Wallpaper by @bobohugifs ㅤ
@phthemes · Post #242 · 25.04.2021 г., 03:01
ㅤㅤ ASTRONAUT 🝐🝐🝐🝐🝐🝐🝐🝐🝐🝐 #dark#aesthetic#glassy#gray ㅤ · Platforms: Android and iOS · Theme by @phthemes ㅤ
Hashtags
@phthemes · Post #249 · 26.04.2021 г., 04:30
ㅤㅤ LITTLE, LITTLE FOX 🝐🝐🝐🝐🝐🝐🝐🝐🝐🝐 #light#aesthetic#glassy#red ㅤ · Platforms: Android and iOS · Theme by @phthemes ㅤ
Hashtags
@phthemes · Post #215 · 15.04.2021 г., 03:31
ㅤㅤ REFLECTION GIRL 🝐🝐🝐🝐🝐🝐🝐🝐🝐🝐 #light#aesthetic#glassy#blue#purple ㅤ · Platforms: Android, iOS and TDesktop · Theme by @phthemes ㅤ
@phthemes · Post #328 · 13.06.2021 г., 20:27
ㅤ BLACKPINK 🝐🝐🝐🝐🝐🝐🝐🝐🝐🝐 #light#kpop#glassy#pink ㅤ · Platforms: Android, iOS and TDesktop · Theme by@phthemes ㅤ
@phthemes · Post #310 · 28.05.2021 г., 16:26
ㅤ BARBIE (Mariposa & the Fairy Princess) 🝐🝐🝐🝐🝐🝐🝐🝐🝐🝐 #dark#movie#glassy#pink#purple ㅤ · Platforms: Android, iOS and TDesktop · Theme by@phthemes · Wallpaper by @bobohugifs ㅤ
@phthemes · Post #251 · 28.04.2021 г., 04:01
ㅤ BILLIE EILISH 🝐🝐🝐🝐🝐🝐🝐🝐🝐🝐 #dark#singer#glassy#green ㅤ · Platforms: Android, iOS and TDesktop · Theme by @phthemes ㅤ
@phthemes · Post #7 · 08.08.2020 г., 19:27
ㅤ ㅤㅤ ، 𖤓 ──┈ TUTORIALS 1. How to search in the channel? Note: You can just tap on the hashtags and activate the "Search" function on the channel. Search by luminosity; #Dark#Light Search by genre; #Aesthetic#Anime#DigitalArt#Cartoon#HarryPotter#Kpop#Illustration#Movie#Realistic#Sanrio#Singer Search by subgenre; #glassy#pastel Search by color; #beige#blue#brown#gray#gold#green#multicolor#nude#pink#purple#orange#red#salmon#turquoise#yellow Note: Other words will be found by typing it directly into the search located in ⇨ ⋮ (3 dots on the upper right side) ㅤ