@MV_Kpop · Post #5911 · 27.05.2020 г., 11:45
REDSQUARE - Color Full • 1080P HD #Redsquare@MV_Kpop
Hashtags
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
Пребарај: #redsquare
@MV_Kpop · Post #5911 · 27.05.2020 г., 11:45
REDSQUARE - Color Full • 1080P HD #Redsquare@MV_Kpop
Hashtags
@MFARUSSIA · Post #29714 · 09.05.2026 г., 06:58
🔴#LIVE from the #RedSquare: Parade marking the 81st Anniversary of the Victory over Nazism 🔴X (ex-Twitter) 🔴Facebook 🔴RT English 🔴Ruptly #Victory81
Hashtags
@rusembsg · Post #4053 · 09.05.2025 г., 07:01
🔴#LIVE from the #RedSquare: Parade marking the 80th Anniversary of the Victory over Nazism 🔴X (ex-Twitter) 🔴Ruptly #Victory80#Parade
Hashtags
@BarykinaLiubov · Post #2152 · 21.10.2025 г., 17:13
Только гимнастки могут так оригинально профессионально поздравить с днём рождения Only gymnasts can congratulate you on your birthday in such an original and professional way #LiubovBarykina #Redsquare #Moscow #Artist #Champion #Choreographer 💃🏽🔥💥
@russianhouseathens · Post #6897 · 09.05.2025 г., 07:36
🔴#LIVE from the #RedSquare: Parade marking the 80th Anniversary of the Victory over Nazism 🔴X (ex-Twitter) 🔴Facebook 🔴Ruptly 🔴Telegram-stream (with commentary in Russian) #Victory80#Parade
Hashtags
@russian_embassy_in_cambodia · Post #4497 · 09.05.2025 г., 06:57
🔴#LIVE from the #RedSquare: Parade marking the 80th Anniversary of the Victory over Nazism 🔴Ruptly #Victory80#Parade
Hashtags
@rusconct · Post #2614 · 09.05.2025 г., 07:04
🔴#LIVE from the #RedSquare: Parade marking the 80th Anniversary of the Victory over Nazism 🔴X (ex-Twitter) 🔴Ruptly #Victory80#Parade
Hashtags
@rusembpak · Post #1385 · 09.05.2025 г., 07:02
🔴#LIVE from the #RedSquare: Parade marking the 80th Anniversary of the Victory over Nazism 🔴X (ex-Twitter) 🔴Ruptly #Victory80#Parade
Hashtags
@rusembmalta · Post #2003 · 09.05.2025 г., 07:37
🔴#LIVE from the #RedSquare: Parade marking the 80th Anniversary of the Victory over Nazism 🔴X (ex-Twitter) 🔴Facebook 🔴Ruptly 🔴Telegram-stream (with commentary in Russian) #Victory80#Parade
Hashtags
@aseanrussia · Post #1617 · 09.05.2025 г., 08:57
🔴#LIVE from the #RedSquare: Parade marking the 80th Anniversary of the Victory over Nazism 🔴X (ex-Twitter) 🔴Facebook 🔴Ruptly 🔴Telegram-stream (with commentary in Russian) #Victory80#Parade
Hashtags
@rusembmalta · Post #2481 · 09.05.2026 г., 07:00
Dear friends, Happy Victory Day! You can watch the live broadcast of the Victory Day Parade from Red Square, Moscow, in English, and join millions in honoring the courage, sacrifice, and historic triumph of the Great Victory. 📍 Live stream (English): https://ruptly.video/event_route?link_id=cc58e406-c40c-41ed-b2eb-f17db3890965&provider_id=42&direction=video #VictoryDay#May9#RedSquare#GreatVictory
@flytezjet · Post #2139 · 07.11.2025 г., 09:54
🇷🇺 Ноябрьские ночи в Москве www.flytezjet.com 🇰🇬 Карача Москва түндөрү www.flytezjet.com 🇬🇧 November nights in Moscow www.flytezjet.com #TezJet#Moscow#FlyTezJet#TezDestinations#RedSquare#TezToMoscow