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 слични објави

Пребарај: #awakening

当前筛选 #awakening清除筛选
✨Lioness⚜️Rising✨🪽♾️

@lionessrises · Post #113333 · 11.05.2026 г., 13:15

🔥 Becoming More Human The more I awaken… the more human I feel. Not less attached… not floating somewhere above it all… but more here than I’ve ever been. More present… more grounded… more complete. It’s strange, because I used to think awakening meant escaping the human experience… rising beyond it. But what I’ve found is the opposite. The more the noise falls away… the more real everything becomes. The more I feel… the more I see… the more I understand what it actually means to be alive. There’s no need to chase… no need to force… no need to become something else. It’s like I’m finally standing in my own life… fully. Not observing it from a distance… not trying to fix it… just being in it… and that feels like peace. Maybe awakening isn’t about leaving humanity behind… maybe it’s about finally arriving in it. ZF 🔥 #awakening#presence#grounded#selfrealization#growth#consciousliving ✨〰️✨〰️✨ Take only what resonates 💫 @Ascension_A_Memeoir✨🪬

🐎 Mustang Debbie Channel🐎

@mustangdebb · Post #47913 · 10.05.2026 г., 18:57

https://x.com/zachqfish/status/2053461293190062283?s=52 🙏 Why We Cannot See Creator Sometimes people ask, “Why can’t we see Creator?” It’s a beautiful question, and one that has echoed through humanity since the beginning of time. Maybe the answer is simpler than we think. A child in the womb cannot see its mother. It cannot comprehend the world beyond the walls that surround it. It does not know who is feeding it, protecting it, or sustaining every breath and heartbeat. And yet, the mother is there the entire time... loving, nourishing, and holding that child in perfect care. The child may not understand the mother, but the mother understands the child completely. In many ways, we are no different. We live inside a vast and mysterious universe, surrounded by intelligence, beauty, and order far beyond what our minds can fully grasp. We may not be able to see Creator with our physical eyes, but we can witness the fingerprints of Creator everywhere... in the rhythm of our hearts, the precision of nature, the power of love, and the quiet inner knowing that reminds us we are never alone. Perhaps this life is a sacred womb. A place where our souls are growing, learning, and preparing for a greater birth into a reality we cannot yet imagine. And just like the child in the womb, we may not fully understand what holds us. But we are held. We are guided. We are loved beyond measure. One day, when the veil lifts and our awareness expands, we may realize that what we were searching for was never separate from us. Creator was not hidden. Creator was carrying us all along. ZF 🔥 #Creator#Faith#SpiritualAwakening#TheWayOfBeing#DivinePresence#Awakening#Consciousness#NewEarth#TrustTheJourney#ZF🔥