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

Резултати

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

Пребарај: #tapps

当前筛选 #tapps清除筛选

TON Launches Loyalty Program ❤️ The TON ecosystem has introduced the TON Loyalty Program — a Tapps rewards layer that turns everyday actions in Telegram Mini Apps into collectible points with built-in “cashback.” How Tapps mechanics work: 🔵 Users open any partner Mini App 🔵 They spend Stars (games, purchases, donations — as usual) 🔵 A smart contract automatically credits Star Points to their TON wallet 🔵 Accumulated points can be redeemed for: • Telegram Premium • Exclusive & Rare Telegram Gifts • Surprise Gift-Boxes Why it’s a welcome addition: 🔵 A portion of Stars spent is returned as points 🔵 All Mini Apps share a unified loyalty system 🔵 An on-chain counter shows exactly how many points you’ve earned and for which actions For long-time Star users, it’s a handy form of cashback. For newcomers, it’s a great reason to explore TON Mini Apps and see the benefits firsthand. 🙃 Check your points here #TON#Tapps#Loyalty#TelegramPremium#MiniApps

☀️Meet the Mini App from Architec.ton! Yesterday Architec.ton team have released their wallet, but banks (shares) can still be purchased to receive $ARС tokens and become a co-owner of the project. Currently the price of $BNK is 1.5 $TON (~$11) The team is currently working on fixes. The #swap button is not yet available. The bugs will be fixed within a short time. 🔜About staking and liquidity All $BNK and $ARC were successfully credited to those who purchased them. If anyone has questions, please contact support @architecton_support. 📈$BNK can be staked now if you want to earn $ARC income. Liquidity in $BNK and $ARC has not yet been added to the swap, so it will not be possible to sell them on the DEX now. This was done according to pre-agreed principles in order to prevent a dump, since the task of the project team is to ensure long-term #liquidity due to the demand for our token. However, the team’s plans include entering the stock exchanges. #wallet#tapps#DEX#gamefi#AMA

🐶$DOGS recent status summary 🦴Tokenomics Total supply: 550B tokens Community supply: 81.5% (fully unlocked)🔥 ‣ Telegram airdrop participants: 73% (all unlocked after TGE) ‣ Future rewards: 8.5% ‣ Team: 10% (12-month linear unlock) ‣ Liquidity and listing: 8.5% 🦴Token Withdrawal Go to @dogshouse_bot and click on the location you want to withdraw, which is divided into CEX and non-custodial wallets. ‣ CEX: 👛@Wallet, 📈Bybit , ✖️OKX ‣ Non-custodial wallet: Tonkeeper, MyTonWallet 🦴Pre-market OKX pre-market contract trading, the pre-market trading contract will be delivered at 12:00 PM (UTC) on August 19th. Those who place orders should pay attention to this time, as the market may fluctuate violently. 🦴Spot trading Please take note of the following schedule: ‣ Deposits will open at 9:00 am UTC on August 14 ‣ Call auction will take place from 11:00-12:00 pm UTC on August 20 ‣ Spot trading open at 12:00 pm UTC on August 20 ‣ Withdrawals will open at 10:00 am UTC on August 21 🦴Other considerations If you receive Dogs PEPE tokens, please note that this is a Pixiu plate, don't waste Gas Swap, the Gas will be eaten. Token address of $DOGS is: EQCvxJy4eG8hyHBFsZ7eePxrRsUQSFE_jpptRAYBmcG_DOGS Pay attention to the last 4 chars! ⚠️ Trade $DOGS here 📈Bybit | ✖️OKX | 🧊Bitget #dogs#durov#tapps#vk#social#cex#wallet