@QuietWorld · Post #6814 · 29.10.2019 г., 06:30
Correction does much, but encouragement does more. #kindness@quietworld🍃
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
Пребарај: #kindness
@QuietWorld · Post #6814 · 29.10.2019 г., 06:30
Correction does much, but encouragement does more. #kindness@quietworld🍃
Hashtags
@QuietWorld · Post #6808 · 28.10.2019 г., 06:30
He who helps early helps twice. #kindness#life @quietworld🍃
@learnRCRussian · Post #5825 · 13.12.2025 г., 15:00
Служба спасения сов! Owl Rescue Service! 🦉Our fighters are rescuing an owl that got tangled in the fiber-optic cable from an FPV drone. • Сова (совы) (femin.noun) [sa-va (so-vy)] An owl(s) #news #kindness 😎RCR | Support | Boost
@learnRCRussian · Post #5821 · 12.12.2025 г., 13:00
Sometimes the world seems very difficult and complicated, doesn't it? 😽It is so difficult to remain kind and humane in our time, the harder our life is, the more pleased we are with videos where people support and understand each other, where a kind joke warms our hearts and makes our world brighter! 😽Yes, we are busy with our own affairs, burdened with problems, family events. We forget about the power of human kindness. A young girl, on her first day at work, is very worried. Every plate feels like a test, every look from the customer feels like a judgment. But instead of impatience, she is greeted with smiles. Instead of irritation, there are encouraging shouts and friendly hugs. The guests, as if sensing her vulnerability, choose sympathy. They thank and cheer her up. 😽This is a deep truth. Our strength is not in perfection, but in kindness. We offer kindness to others and choose it in ourselves. Video: Новый мир #kindness #brief_and_interesting #Russian_culture 😎RCR | Support | Boost
@QuietWorld · Post #7202 · 24.02.2020 г., 08:38
#life#love#kindness @quietworld🍃
@QuietWorld · Post #6779 · 23.10.2019 г., 23:30
🔖“What we have done for ourselves alone; dies with us. What we have done for others and the world; remains and is immortal.” · Albert Pike · #life#kindness#truth @quietworld🍃
@QuietWorld · Post #7625 · 07.10.2020 г., 02:01
#life#kindness#inspiration @quietworld🍃
Hashtags
@googlefactss · Post #40077 · 13.11.2025 г., 03:00
World Kindness Day, from the World Kindness Movement, is a universal awareness day about promoting the importance of being kind to each other, to yourself, and to the world, and is celebrated on the 13th of November every year. Celebrate by being kind online too. [Source] @googlefactss #Kindness#BeKind
@QuietWorld · Post #6748 · 19.10.2019 г., 13:00
Happiness is not so much in having as in sharing; We make a living by what we get, but we make a life by what we give. – Norman M. #kindness#happiness#life @quietworld🍃
Hashtags
@QuietWorld · Post #7764 · 24.03.2021 г., 22:24
#wisdom#kindness#truth @quietworld🍃
@QuietWorld · Post #6811 · 28.10.2019 г., 13:01
We love those people who give with humility, or who accept with ease. #kindness#gratitude @quietworld🍃
Hashtags
@QuietWorld · Post #7694 · 24.11.2020 г., 00:54
#love#kindness#life#truth @quietworld🍃