TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #22 · 19 јан.

Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic

Hashtags

Резултати

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

Пребарај: #aidating

当前筛选 #aidating清除筛选
TON Crypto News

@toncoin_rap · Post #156 · 19.09.2024 г., 14:29

🎧⤴ TON Dating: AI-Powered Compatibility Checks with ChatGPT! TON Dating has become the first dating app to integrate ChatGPT, offering a new feature that analyzes compatibility between users. By clicking on the ChatGPT icon in a profile, the AI examines both users' data to determine their match potential. This move aims to enhance the dating experience within a verified, secure community that rewards user engagement with cryptocurrency. The integration sets TON Dating apart, offering a futuristic, AI-driven approach to finding meaningful connections on the platform. 😴👉https://t.me/tondating Chorus: TON Dating's blowing up, with ChatGPT inside, AI's your new matchmaker, taking love on a ride. Swipe right, swipe left, let the AI decide, Finding true connections where ambition and love collide. Verse 1: Step into the game, TON's raising the stakes, AI compatibility, no more heartbreaks. Profiles verified, no scammers in sight, Pay-to-play, yeah, but it feels just right. Girls roll free, boys paying their dues, Crypto rewards for every match you choose. Swipe with intention, love or coin’s the prize, TON Dating's got the edge, no surprise. Chorus: TON Dating's blowing up, with ChatGPT inside, AI's your new matchmaker, taking love on a ride. Swipe right, swipe left, let the AI decide, Finding true connections where ambition and love collide. Verse 2: Ambition meets beauty, the motto’s legit, Profiles vetted hard, so no catfish hit. Vlad’s got a vision, safe space to thrive, No fake accounts here, just the real ones alive. Stack your TON coin, let your profile shine, The app’s got your back with AI design. Success and smarts, it’s the ultimate find, TON Dating’s got that AI mastermind. Chorus: TON Dating's blowing up, with ChatGPT inside, AI's your new matchmaker, taking love on a ride. Swipe right, swipe left, let the AI decide, Finding true connections where ambition and love collide. Verse 3: Crypto’s the future, and dating’s the key, Bringing people closer through technology. ChatGPT whispers, "Is this love or a game?" It’s matchmaking magic, never quite the same. Filter out the fakes, meet your match on screen, High standards, high hopes in this dating scene. From Telegram to TON, the platform's tight, Find your perfect vibe, under AI light. Chorus: TON Dating's blowing up, with ChatGPT inside, AI's your new matchmaker, taking love on a ride. Swipe right, swipe left, let the AI decide, Finding true connections where ambition and love collide. Bridge: So step up to the future, the game just begun, With ChatGPT matching, you might find "the one." It’s a new world, new rules, tech by your side, TON Dating’s the place where love and crypto collide. #TONDating#AIDating#ChatGPTMatch #TONCryptoNewsRapStyle 🎧@toncoin_rap