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

Резултати

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

Пребарај: #bricssummit

当前筛选 #bricssummit清除筛选
Russian Consulate in Cape Town

@rusconct · Post #1919 · 24.10.2024 г., 13:20

🇷🇺Russia proposed to open the BRICS grain exchange, which will allow to ensure food security in the association. President #Putin: It has been suggested to open the BRICS grain exchange that will facilitate the formation of fair and predictable price indicators for products and primary produce, considering its particular role in ensuring food security. The implementation of this initiative will help protecting national markets from negative external interference, speculations and attempts to cause the food shortage artificially. #brics2024#brics#bricssummit

@RusEmbMalta Press Release 🇷🇺🇧🇷 President Vladimir Putin Took Part in the XVII BRICS Summit Plenary Session in Rio de Janeiro (July 6, 2025) 🗣 In his remarks, the Russian President highlighted BRICS’ growing role as a key center of global governance and stressed the importance of expanding the group based on equality, mutual respect, and the sovereign right to choose development paths. 📊 According to IMF data for 2025, BRICS accounts for 40% of the global economy, with a combined GDP (PPP) exceeding $77 trillion – far ahead of the G7’s $57 trillion. 💬Key points from President Putin’s speech: – The world is undergoing tectonic shifts. The outdated unipolar system is giving way to a just multipolar order. – Expanding the use of national currencies is vital. In 2024, over 90% of Russia’s transactions with BRICS partners were in the ruble and friendly currencies. – BRICS is building an open cooperation architecture with the Global South and East – 10 countries already hold BRICS Partner status. – Traditional values, equality, and civilizational diversity are becoming the foundation of a new globalization model. – Developing an independent BRICS payment and settlement system is a strategic priority. 📄The Rio de Janeiro Declaration was adopted at the summit under the theme “Strengthening Global South Cooperation for a More Inclusive and Sustainable Governance.” It includes: ✅ A reaffirmation of commitment to multilateralism and comprehensive UN reform, including Security Council expansion to better represent developing countries ✅ Strong condemnation of unilateral sanctions and the June 2025 military strikes against Iran ✅ Condemnation of terrorist attacks on Russian civilian infrastructure (May–June 2025) ✅ Support for the Palestinian people’s right to self-determination ✅ Emphasis on “African solutions to African problems” as a basis for conflict resolution on the continent 📌 Full text of Remarks by Vladimir Putin at BRICS Plenary Session 📌 Full text of BRICS Rio Declaration 2025. #RussiaBRICS#BRICS2025#GlobalSouth#BRICSsummit