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 слични објави

Пребарај: #uaeblockchain

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

@toncoin_rap · Post #197 · 03.11.2024 г., 16:54

🎧⤴ 🤑 Tether's Game-Changer: Dirham-Pegged Stablecoin Set to Launch on TON Blockchain! Tether is set to unveil a new dirham-pegged stablecoin on the TON blockchain, following its successful integration of USDT, which recently reached 1 billion tokens. This stablecoin, backed by liquid UAE reserves, aims to enhance cross-border payments and facilitate secure transactions in the UAE. Tether's partnership with Phoenix Group and Green Acorn Investments underscores the UAE's growing influence as a global cryptocurrency hub. This launch coincides with the UAE's new licensing framework for stablecoins, positioning Tether as a key player in the region's digital economy. Chorus: Tether's bringing fire with the dirham in the game, Stablecoin's the name, ain't no two the same. On the TON blockchain, watch the future ignite, Secure your transactions, everything feels right. Verse 1: In the desert where the sun shines bright, Tether’s dirham stablecoin takes flight. Backed by reserves, it’s liquid and clean, Digital dirhams, if you know what I mean. From Dubai to the world, we’re breaking the mold, Cross-border cash flows, stories to be told. With every transaction, the trust is built, A new era of finance, no room for guilt. Chorus: Tether's bringing fire with the dirham in the game, Stablecoin's the name, ain't no two the same. On the TON blockchain, watch the future ignite, Secure your transactions, everything feels right. Verse 2: Blockchain's the highway, speeding up the grind, With 160k transactions, we’re redefined. Companies on Fireblocks, joining the race, Tether’s got the vision, setting the pace. UAE's the scene, where crypto thrives, With innovation and rules, it’s where ambition arrives. From USDT’s success to the dirham's embrace, Tether’s changing the game, it’s a whole new space. Chorus: Tether's bringing fire with the dirham in the game, Stablecoin's the name, ain't no two the same. On the TON blockchain, watch the future ignite, Secure your transactions, everything feels right. Verse 3: Regulations in place, clarity to thrive, UAE's got the vision, watch the market come alive. With partners by our side, we’re aiming for the stars, Bringing trust and stability, no matter where you are. From the city of gold, the world we’ll engage, In this digital era, we’re turning the page. Tether's dirham stablecoin, a future so bright, Crypto's revolution, we're ready to ignite. Chorus: Tether's bringing fire with the dirham in the game, Stablecoin's the name, ain't no two the same. On the TON blockchain, watch the future ignite, Secure your transactions, everything feels right. Bridge: So here’s to the future, with crypto in our hands, Building a new world, making bold plans. Tether's on a mission, we’re setting the tone, In the heart of the UAE, we’re claiming our throne. #CryptoInnovation#Stablecoin#UAEBlockchain #TONCryptoNewsRapStyle 🎧@toncoin_rap