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

Резултати

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

Пребарај: #fellowships

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

@rusconct · Post #3305 · 02.02.2026 г., 14:59

🔥🔥🔥 Applications are now open for InteRussia fellowships⭕️ InteRussia is a fellowship program for young professionals worldwide, implemented by the Gorchakov Fund in partnership with leading Russian universities, expert centers, and industry partners. ⭕️ The program offers hands-on professional experience in Russia, direct engagement with top experts, and the opportunity to become part of a global professional community. More than 500 participants from 70 countries have already completed InteRussia fellowships — now it’s your turn to join. Which fellowships can you apply for? ⭕️International Relations (all over the world) ⭕️Oriental Studies (post-Soviet countries, the Middle East, and North Africa) ⭕️Archeologists (post-Soviet countries, the Middle East, North Africa, India, and Pakistan) ⭕️Journalism (South Asia) ⭕️Journalism (the Middle East and North Africa) ⭕️Journalism (Sub-Saharan Africa) ⭕️Russian Studies (all over the world) ⭕️Medicine (all over the world) ⭕️Information Technology (all over the world) ⭕️Electric Power (the Middle East and Africa) ⭕️Energy (Latin America) ⭕️Theatre Arts (BRICS+ countries) ⭕️ More details and application guidelines are available at interussia.com. The InteRussia fellowships are implemented with the support of the Presidential Grants Foundation, Rossotrudnichestvo, and the Ministry of Education of Russia. #InteRussia#fellowships#internships 1️⃣1️⃣1️⃣

Russian MFA 🇷🇺

@MFARUSSIA · Post #28181 · 01.02.2026 г., 21:04

🔥🔥🔥 Applications are now open for InteRussia fellowships⭕️ InteRussia is a fellowship program for young professionals worldwide, implemented by the Gorchakov Fund in partnership with leading Russian universities, expert centers, and industry partners. ⭕️ The program offers hands-on professional experience in Russia, direct engagement with top experts, and the opportunity to become part of a global professional community. More than 500 participants from 70 countries have already completed InteRussia fellowships — now it’s your turn to join. Which fellowships can you apply for? ⭕️International Relations (all over the world) ⭕️Oriental Studies (post-Soviet countries, the Middle East, and North Africa) ⭕️Archeologists (post-Soviet countries, the Middle East, North Africa, India, and Pakistan) ⭕️Journalism (South Asia) ⭕️Journalism (the Middle East and North Africa) ⭕️Journalism (Sub-Saharan Africa) ⭕️Russian Studies (all over the world) ⭕️Medicine (all over the world) ⭕️Information Technology (all over the world) ⭕️Electric Power (the Middle East and Africa) ⭕️Energy (Latin America) ⭕️Theatre Arts (BRICS+ countries) ⭕️ More details and application guidelines are available at interussia.com. The InteRussia fellowships are implemented with the support of the Presidential Grants Foundation, Rossotrudnichestvo, and the Ministry of Education of Russia. #InteRussia#fellowships#internships 1️⃣1️⃣1️⃣

Embassy of Russia in Singapore

@rusembsg · Post #4355 · 02.02.2026 г., 06:51

🔥🔥🔥 Applications are now open for InteRussia fellowships⭕️ InteRussia is a fellowship program for young professionals worldwide, implemented by the Gorchakov Fund in partnership with leading Russian universities, expert centers, and industry partners. ⭕️ The program offers hands-on professional experience in Russia, direct engagement with top experts, and the opportunity to become part of a global professional community. More than 500 participants from 70 countries have already completed InteRussia fellowships — now it’s your turn to join. Which fellowships can you apply for? ⭕️International Relations (all over the world) ⭕️Oriental Studies (post-Soviet countries, the Middle East, and North Africa) ⭕️Archeologists (post-Soviet countries, the Middle East, North Africa, India, and Pakistan) ⭕️Journalism (South Asia) ⭕️Journalism (the Middle East and North Africa) ⭕️Journalism (Sub-Saharan Africa) ⭕️Russian Studies (all over the world) ⭕️Medicine (all over the world) ⭕️Information Technology (all over the world) ⭕️Electric Power (the Middle East and Africa) ⭕️Energy (Latin America) ⭕️Theatre Arts (BRICS+ countries) ⭕️ More details and application guidelines are available at interussia.com. The InteRussia fellowships are implemented with the support of the Presidential Grants Foundation, Rossotrudnichestvo, and the Ministry of Education of Russia. #InteRussia#fellowships#internships 1️⃣1️⃣1️⃣

Oslo fashion

@Inspireandfunny · Post #338 · 04.04.2019 г., 10:48

Don't miss this opportunity👌 for African student #Undergraduate#Scholarship Scholarship Opportunities for African Students (Fully Funded) #Scholarships and #Fellowships Cost: Fully & Partially Funded Country:France City:Paris ❗️Candidates must be a citizen of a sub-Saharan African country Likewise, Candidates must have completed their high school education in a sub-Saharan African country. Deadline 08 April,2019 Open to: All african nations Want to apply? 👇 http://www.sciencespo.fr/students/en/fees-funding/financial-aid/mcmillan-stewart-scholarship