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

Резултати

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

Пребарај: #valentine

当前筛选 #valentine清除筛选
Everything Science

@everything_science · Post #3290 · 17.02.2025 г., 07:44

Single man in china once booked every other seat in a cinema theatre to split up couples on valentine's day. #Valentine 🔔@Everything_Science

Hashtags

🦅 [ perspective ix ]

@perspectiveix · Post #1110 · 14.02.2018 г., 20:00

​​❤️ Valentine's Day 2018 - The Cost Of Love Love it or loathe it, #Valentine's Day is an important date for the 🇺🇸 economy. According to the National Retail Federation (NRF), the average American will spend $143.56 on gifts this year, with total planned nationwide spending $19.6 billion. 55% of people are going to celebrate with jewelry ($4.7 billion), an evening out ($3.7 billion) and flowers ($2.0 billion) the top spending categories. 🚀@PerspectiveIX 🌀 ⁣http://prs.pctvix.co/TelegramIX

Hashtags

🚀 LAUNCH DAY #VALENTINE is going to enter the market. Chart’s will heating up. 📜 Contract: 0x3942B1e2F8B4B2d7921CE49A1fC0f805295F381C 💰 Tax: 3/3 🚀 Launching on 8/8 at 12:00 PM UTC ⏰ ➡️Ave on Broad ➡️Top trending booked ➡️#Valentine updated on #Dextool 🟢Chart: https://www.dexview.com/bsc/0x3942B1e2F8B4B2d7921CE49A1fC0f805295F381C ✉️Telegram https://t.me/bsc_Valentine 🐦Twitter https://x.com/bsc_Valentine

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40655 · 13.02.2026 г., 23:01

Saint Valentine’s Day, or simply Valentine’s Day, is celebrated on the 14th of February, but primarily in western societies. The day has been named after one or more martyrs of the early Christian era named Valentine or Valentinus who lived sometime in the 3rd century CE and were killed for defying oppressive laws directed either against Christians or young lovers in the Roman Empire. [read more here] @googlefactss#history#love#Valentine

APKPure_Official

@apkpurechannel · Post #2873 · 21.02.2026 г., 11:31

🔥💗Grow a Garden #Valentine Part 2 Event 👀#Leak 🚀💘Feb 22 - Mar 1 💕💕More Hearts!! Expect a huge variety of new Valentine's-themed cosmetics In the Valentine's part 2 update! With all these new features, you'll create heart-filled gardens, plus a brand-new quality-of-life update for the Heart Blossom Seed and much more in Grow a Garden! 💕💕💕 #gag#trade🌞#growagarden❤️#valentine🐝#garden 📅🎁Check out GAG Giant pet giveaways on TradeKitsune. Add @APKFreeDownloader_Bot to get any apk you want.

Kraze magazine Instagram Update Vogue Korea has released its February 2026 issue with Jimin as the main cover star. This edition, released in February, carries a Valentine’s theme and features a visual concept highlighting Jimin’s artistic character and personal identity. After Vogue published the February 2026 cover, Jimin ranked number one in global trending topics. Follow @kraze.official for daily and reliable updates on K-pop news, trends, events, and everything in between! 💌 [email protected] Source: Vogue Korea #Jimin#BTS#Vogue#VogueKorea#Valentine -@All_BTS_Updates