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

Резултати

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

Пребарај: #tribute

当前筛选 #tribute清除筛选
TONlines – News

@tonlines · Post #7328 · 22.05.2025 г., 14:44

Tribute: Essential Rules for Content Monetization #Tribute#Telegram Tribute channel emphasizes the importance of rules for creators monetizing their Telegram channels. Key rules are summarized in easy-to-understand cards, and further details can be found on their Wiki. Source: link @tonlines

TONlines – News

@tonlines · Post #6895 · 22.04.2025 г., 12:43

Tribute: Launch Your Online Store on Telegram Effortlessly #Telegram#Tribute Tribute offers tools for quickly setting up an online store on Telegram, including features like collections, preliminary shipping cost calculation, and LinkHub for product aggregation. The channel seeks feedback on additional features to enhance user experience. Source: link @tonlines

TONlines – News

@tonlines · Post #7084 · 07.05.2025 г., 14:44

Tribute Makes Payments Easier for Creators #Tribute#Stars The channel @TributeNewsEN highlights a new feature allowing creators to generate web payment links for digital products. These links enable payments in rubles or euros via bank cards, facilitating transactions on social media and other platforms. Source: link @tonlines

TONlines – News

@tonlines · Post #7294 · 20.05.2025 г., 12:35

Tribute Introduces LinkHub for Content Monetization #Tribute#LinkHub Tribute | Monetize your content introduces LinkHub, a centralized platform where users can display products, manage donation goals, and consolidate all paid channels. This tool allows easy sharing of all offerings in a single link. Source: link @tonlines

TONlines – News

@tonlines · Post #7071 · 06.05.2025 г., 16:49

Tribute Empowers Creators with Public API Access #Tribute#webhooks @TributeNewsEN introduces public API access keys, allowing for seamless data integration with external services. Currently, creators can utilize two webhooks for subscription management. Source: link @tonlines

TONlines – News

@tonlines · Post #6914 · 23.04.2025 г., 13:15

Tribute: Celebrating International Creator Day #Tribute#creators Tribute | Monetize your content celebrates International Creator Day on April 23, recognizing the creativity and hard work of content creators. The channel encourages creators to continue entertaining and inspiring audiences. Source: link @tonlines

TONlines – News

@tonlines · Post #6775 · 15.04.2025 г., 12:26

⚡️Tribute: Updated Affiliate Program Announcement #Tribute#affiliate The Tribute channel has updated its affiliate program to help content creators expand their audience and enable partners to earn money by promoting private channels. Detailed information is available on their wiki. Source: link @tonlines

TONlines – News

@tonlines · Post #6719 · 11.04.2025 г., 14:52

Tribute: Voice Actor Shares Success Story #Tribute#voice Tribute shares insights from a voice actor who has mastered monetizing talent using the platform. Learn how they turn their passion for voice acting into income. Source: link @tonlines

Addis Standard

@addisstandardeng · Post #21347 · 09.02.2026 г., 10:47

#Tribute: Professor Asmarom Legesse: Pioneer Scholar Who Illuminated the #Gadaa System to the World Professor Asmarom Legesse, the Eritrean-born anthropologist who redefined African democratic discourse, passed away on January 31, 2026, aged 94. In this tribute, Teferi Tafa notes the Harvard-trained scholar "spent over half a century documenting the #Oromo Gadaa system, dismantling colonial myths that dismissed indigenous #African governance as primitive." The author explains that Asmarom’s works revealed "a sophisticated constitutional order" featuring rotational leadership and term limits. He proved that Gadaa was "a highly developed system of checks and balances... that had governed Oromo society for centuries." Tafa emphasizes that Asmarom’s legacy of "intellectual decolonization" establishes him as a hero to the Oromo and a titan of global anthropology. https://addisstandard.com/?p=55081