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

Резултати

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

Пребарај: #nfts

当前筛选 #nfts清除筛选

Aqua Army is launching its first NFT project🌊 Mint 31/05/22 🚀 Release/reveal 06/06/22🧨 Aqua Army is an exclusive collection of 4,444 unique #NFTs that submerge you into a world of deep-sea adventure, purpose and collectibles living on the Ethereum network🐟 Every NFT is hand drawn with over 500+ traits over 8 sea characters living in different waters. 1 mint of 0.09ETH will clean up 300 plastic bottles from our oceans. A great portion of the proceeds will be donated to 5 non-profit based charities, who they've officially partnered with💰 Any Whitelist member will automatically be enrolled into a prize draw to WIN one of five AA NFTs 💵💵 Twitter 👇 https://twitter.com/AquaArmyNFT Join Minting👇 https://bit.ly/3NLQmgF Website & WL👇 https://aquaarmynft.com/?whitelist=true

Hashtags

​​🎙Aqua Army is launching its first NFT project🌊 Mint = 17th of May 🔥 Reveal/release = 23rd May🔥 Aqua Army is an exclusive collection of 4,444 unique #NFTs that submerge you into a world of deep-sea adventure, purpose and collectibles living on the Ethereum network🐟 Every NFT is hand drawn with over 500+ traits over 8 sea characters living in different waters. 1 mint of 0.09ETH will clean up 300 plastic bottles from our oceans. A great portion of the proceeds will be donated to 5 non-profit based charities, who they've officially partnered with💰 Any Whitelist member will automatically be enrolled into a prize draw to WIN one of five AA NFTs 💵💵 Twitter👇 https://twitter.com/AquaArmyNFT Discord👇 https://discord.com/invite/2ZnscjzSJZ Website & WL👇 https://aquaarmynft.com/?whitelist=true

Hashtags

🚀🚀The intelligent investors💯💯

@the_intelligent_investors · Post #42 · 15.12.2021 г., 15:18

Rad rabbits intensified! Sold over 1000 Rad rabbit #NFTs in less than 24 hours Last chance to get your rad rabbits with $AAA : http://radrabbbits.org 5600 #NFTs already sold Funds and projects are considering these #NFTs as bluechips Don’t miss out on these #NFTs

Hashtags

News and Tips

@NewsAndTipsNT · Post #3166 · 02.03.2025 г., 17:35

#Telegram now displays #NFTs in the profile background. You can click on them individually to view their details. Only pinned NFTs appear in the background, they appear exactly like your pinned order.

TONlines – News

@tonlines · Post #6920 · 23.04.2025 г., 17:20

TON Community: Guide to the Revival of NFTs #NFTs#Telegram The TON Community discusses the resurgence of NFTs in 2025, highlighting their integration into Telegram for easy use without wallets or gas fees. Animated stickers, digital gifts, and collectible items are now easily accessible. For more details, check their latest blog on TON NFTs. Source: link @tonlines

🏆 Premium, NFT, Tokens

@giiveaways · Post #3315 · 29.11.2024 г., 08:53

Boost Your Wins! 🏹 Complete tasks, grow your streak, and earn rewards like NFTs and TON tokens. 🎉Grand Lottery with 2,000 TON ends December 26th! 👉 Start now: https://t.me/tapps/app ➖➖➖➖➖➖➖➖➖➖➖ #NFTs#TON

Hashtags

Walken.io - Announcement

@walken_channel · Post #52 · 11.03.2022 г., 09:19

Next Monday we are releasing the beta version for the first 2000 testers on iOS. Are you excited? We definitely are! 🎉🎉🎉 P.s. you still can sign up for the whitelist on the website. $WLKN #gamefi#nfts

Hashtags

Walken.io - Announcement

@walken_channel · Post #39 · 21.02.2022 г., 14:29

Get ready for sprint🦶 A road race with a distance of 60 to 400 meters where most speed is the key. 3..2..1 - and the competition is kicked off. Just challenge a randomly selected rival and win the race😉 $WLKN #gamefi#nfts

Hashtags

123•••56
ПретходнаСтраница 1 од 6Следна