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

Резултати

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

Пребарај: #vanillafinance

当前筛选 #vanillafinance清除筛选

✨Level up and unlock daily cash rewards, up to $2,100! 🎉 Upgrade your level to grab massive rewards! 🔝The more you upgrade, the better your chances to win! ➡️How to participate Join Vanilla Finance Be at level 8 or above. Upgrade at least 1 level during the event. 🎲Winner Selection Winners will be randomly selected. Probability increases based on the amount paid for level upgrades. 🏆Daily Rewards 🥇 $100 — 1 winner 🥈 $50 each — 2 winners 🥉 $15 each — 7 winners 🎙Winner Announcement Winners will be announced every 6:00 UTC on Vanilla finance's official TG channel✔️ 📆Event Period: Nov 19, 9:00 — Nov 25 9:00 UTC Rewards will be distributed every day after the winner announcement. 🍦Ready to be the lucky winner?🏆 #TON#contest#VanillaFinance

🍦 Join Vanilla Finance Huge Community Giveaway! Share 💵10,000 worth of USDT prize pool! ✔️Complete all daily tasks to win big! ✔️RT & Like on X ✔️Tag 3 Frens on X 🗓️ May 21-27, 2025 (8:30PM GMT+8) Start on Galxe✔️ #VanillaFinance#Giveaway#TON

😊Memecoin Spot Trading is Now Live on Vanilla Finance on Telegram! Start spot trading your favorite memecoins on #VanillaFinance today! The #1 Trading Volume exchange on Telegram. We’re the 1st Exchange to bring you: 🪙 Memecoin Spot Trading ⚡️ 10,000x Leverage ❌ No Liquidation Risk ↗️ Exciting memecoin trading events are on the way! Stay tuned for upcoming massive reward events 🎁 ❤️ Join Vanilla mini-app now and try spot trading! #meme#miniapp#telegram#web3

🍦Vanilla Finance: Project Updates Vanilla Finance announced that its TGE has been postponed to Q2 2025. According to the team, this decision was made due to unfavorable market conditions and aims to ensure the most successful launch possible. The extra time will allow them to refine the Total Return Swap (TRS) product, which developers believe can become a cornerstone of DeFi infrastructure and unlock new income opportunities. In preparation for the TGE, the team is also deepening cooperation with leading centralized exchanges and forming partnerships with players such as #CoinMarketCap and BNB Chain by participating in their MVB and CMC Labs programs. 🍦Mini-app #TGE#CMC#VanillaFinance

❤️Vanilla Finance Closes Pre-Seed Investment Round ✔️ Singapore, November 26, 2024 – Vanilla Finance, the leading exchange by trading volume on #Telegram, has announced the successful closure of its Pre-Seed investment round. Spearheaded by industry giants like Paper Ventures, UOB Ventures, and ABCDE Labs, the round also attracted notable participants such as #HTX Ventures, #Ocular, #Openspace, #Y2 Ventures, and angel investors from #STEPN, #Scroll, #XAI, and more. 🔫A Game-Changer in the Digital Asset Space Since its launch, #VanillaFinance has made waves, amassing over $8 billion in USDT trading volume within just 60 days. This meteoric rise is further validated by winning the prestigious #Binance MVB Season 8, a recognition of the platform’s cutting-edge solutions and market leadership. 👏Visionary Growth and User-Centric Innovation With fresh funding and institutional backing, Vanilla Finance is on a mission to redefine crypto trading by: • Simplifying User Experience: Introducing intuitive, secure features tailored for both novices and experts. • Expanding Offerings: Launching a spot market, with a focus on meme trading pairs, and rolling out features like a meme creator platform, staking products, and futures trading. • Regional Focus: Targeting Southeast Asia and APAC with localized services, multilingual support, and integration with regional payment systems. 💰Institutional Confidence in a Bright Future The involvement of strategic investors highlights Vanilla Finance’s potential. A UOB Ventures spokesperson praised the platform’s innovative approach, while Danish Chaudhry of Paper Ventures noted, “Vanilla Finance’s expansion aligns perfectly with the Southeast Asia and APAC markets’ untapped opportunities in digital finance.” 📖Building a Next-Generation Ecosystem Beyond trading, Vanilla Finance is creating an ecosystem that prioritizes community engagement and innovation. With its unique approach to meme trading and user-focused features, the platform is poised to set a new benchmark in digital asset trading. ✈️The Future Starts Here: Vanilla Finance is committed to serving the next 100 million users, shaping a more inclusive, engaging, and forward-thinking crypto landscape. ❤️ Join Vanilla mini-app now and get as much $CONE as you can before the airdrop!