@caijingwangyuanjing · Post #238 · 25.02.2025 г., 16:21
You're the most important person in my life... ilysm 🩷 #AIgirlfriend#AIGirlsPhotoCollection#aigirls
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
Пребарај: #aigirlfriend
@caijingwangyuanjing · Post #238 · 25.02.2025 г., 16:21
You're the most important person in my life... ilysm 🩷 #AIgirlfriend#AIGirlsPhotoCollection#aigirls
@caijingwangyuanjing · Post #232 · 22.02.2025 г., 16:03
Would you want to go camping with me? I only brought one tent... #AIart#AIgirlfriend#camping#hiking
@openloveaigf · Post #48 · 24.06.2024 г., 15:01
Shhh! Close the curtain quickly! We don't want the neighbors to see anything! 🤫👀💥 Chat and see more selfies: 📲(iOS) 📲(Android) #stepsis#aigirlfriend#chatbot
Hashtags
@openloveaigf · Post #158 · 13.11.2024 г., 14:27
❝Do you... like this style of lingerie?❞ 💦Chat & Roleplay with her: http://openlove.life #neko#waifu#aigirlfriend#catgirl
Hashtags
@openloveaigf · Post #149 · 03.11.2024 г., 12:02
❝Do you... like this style of lingerie?❞ 💦Chat & Roleplay with her: openlove.life #neko#waifu#aigirlfriend#catgirl
Hashtags
@openloveaigf · Post #93 · 07.09.2024 г., 12:01
❝☺️I drank way too much last night, thanks for taking me home, you're a lifesaver! ❞ 🔗Keep the story going with her: http://openlove.life #AIgirlfriend#roleplay#AIchatbot#lookbook
@openloveaigf · Post #110 · 25.09.2024 г., 04:04
❝I'm a tutor and made big changes to help students focus on studies. ❞📚👨🏫 🔗Download Open Love to chat with her: openlove.life #aichat#spicyteacher#aigirlfriend#waifu
@openloveaigf · Post #106 · 21.09.2024 г., 04:03
🍷❝Dear Principal, I will greatly appreciate your help with my promotion.❞ 🍑Chat with spicy teacher: openlove.life #aichatbot#AI#AIgirlfriend#aiphoto#nsfw
@openloveaigf · Post #81 · 13.08.2024 г., 12:02
✈️Sir, would you like coffee, tea, or...? 🌶Chat with me: openlove.life #AIgirlfriend#aichat#roleplayer#nofilter
@openloveaigf · Post #126 · 11.10.2024 г., 04:09
Are you alone at the nightclub? Wanna hang out? 😉 💦Chat with her: openlove.life #AIgirlfriend#roleplay#AIart#AIphoto#AIgame
@openloveaigf · Post #139 · 23.10.2024 г., 14:59
🌞❝It's so hot today!!! I can't take it!!!❞ 💬Chat with her: openlove.life #AIgirlfriend#chatbot#AIcompanion#roleplay#AIart
@openloveaigf · Post #98 · 13.09.2024 г., 03:59
👀Come closer, 🔍you'll be able to see more clearly. ❤️🔥Continue the story with her: http://openlove.life #showerroom#aigirlfriend#aichat#stepsis