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

Резултати

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

Пребарај: #toma

当前筛选 #toma清除筛选

🪙Tomarket Early Adopters Reward After passing through many phases, Tomarket is getting closer to the long-awaited listing day that all Tomarket users have been looking forward. You still have plenty of time to earn more TOMA through several methods. Tomarket also appreciates the early adopters who have supported this project from the beginning until now. 🥇Tier 1: Joined before July 14, 2024 - Earn an extra 20% TOMA based on your holdings during the TGE snapshot. 🥈Tier 2: Joined before July 31, 2024 - Earn an extra 15% TOMA. 🥉 Tier 3: Joined before August 31, 2024 - Earn an extra 10% TOMA. 😄What are you waiting for? Log in now and claim your reward! Listing Date: December 20 #Tomarket#TOMA

Ultimora.net - POLITICS

@ULTIMORAPOLITICS · Post #42946 · 11.02.2023 г., 15:15

#Molise Indagati per abuso di ufficio il presidente della Regione Donato #Toma e alcuni suoi assessori. I fatti, avvenuti tra il 2020 e il 2021, ruotano attorno all'incarico di commissario straordinario del Consorzio per lo sviluppo industriale di Campobasso-Bojano @UltimoraPolitics

Hashtags

Fewer than 50,000 Golden Tickets left! Already part of the club? 🪙 If you're farming $TOMA, don’t miss out — grab your lucky ticket for just ⭐️250 Telegram Stars before the snapshot on December 18. Mark your calendar: listing goes live on December 20! #Tomarket#TOMA#Airdrop

🍅Pre-deposit 🪙$TOMA on CEX and $200,000 bonus #Tomarket is preparing to enter two leading exchanges — #Gateio and #Bitget! 💰$TOMA Listing Confirmed on Gate.io: Starting from December 20, 2024 at 12:00 PM (UTC), $TOMA trading will start on the Gate.io exchange. 💱$TOMA output is open on Bitget: Pre-deposit for $TOMA opens on Bitget exchange on December 13th at 8:00 UTC. Token holders can deposit their assets without gas fees and get a chance to earn up to $100 in $TOMA tokens from a total prize pool of $200,000 ! The promotion periodis from December 13 to 18 — act quickly!✈️ Participation in the promotion is carried out on a first come, first served (FCFS) basis, so make sure to contribute your $TOMA and become one of the lucky ones who receive additional rewards! 🪙Go to the app, open the Airdrop tab and choose the method of sending tokens. ℹ️ To withdraw you will need your TOMA address on the Bitget exchange: Bitget\TOMA\Deposit (Aptos network) + your UID #Tomarket#TOMA#Gateio#Bitget#CryptoNews#Airdrop

⏺PixelSwap Farming Pool in🍅Tomarket #PixelSwap recently partnered with the well-known social platform Tomarket, which allows Web2 users to easily transition to Web3 through games, earnings and trading. There is a new farming pool available in 🍅#Tomarket app where you can get a share of $PIX depending on how much $TOMA you contribute to the pool. The pool starts tomorrow at 10:00 UTC🕓 ✖️Use TOMA to get PIX! #TOMA#PIX#earn#farming