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

Резултати

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

Пребарај: #marriage

当前筛选 #marriage清除筛选
RTDocumentary

@rtdocumentary · Post #790 · 19.05.2022 г., 16:01

'There are never kisses at weddings. We will start talking to each other in a month or so'. These are the words of the Kalderash Gypsy Andrei, who was married at 12. When he turned ten, his parents started looking for a young bride. Child marriage is common in Roma villages. Whether the kids want it or not, no one asks. Watch Andrei's story in our video. What goes on inside this unusual culture? Check out the film Romany Romance. #video#marriage Follow: https://t.me/rtdocumentary

Pensive|

@PensivePost · Post #5148 · 29.04.2021 г., 09:53

Marriage Describing life without marriage is not possible. At the right age, we do marriages if you don't want to marry people judge you differently, human is social animals. We need each other's help, this help may be for physical satisfaction or following culture and rules by the family. As you know two types of marriages happen all around the world first one is love marriage or 2 arrange marriage. I don't need to tell you about both you are aware of those things even in simple lines I would like to describe it. 1. Love marriage Love happens in school or colleges where we see new, new faces and characters. That attracts us their style of talking, face, spot or writing bla. bla... We can not fall in love exactly by one accident we fall in love by our habits and wishes match to each other and when we help each other. Many authors have described love in many forms. Love is always standing separately from any other subjects. Don't waste your life in love. You will get many people to tell you like this but what is there without love. Love gives you happiness and sadness, joy and gloom, daring and fear, respect and disesteem, victor and failure. Someone has said everything is possible in love and war. You can lose your mind and become crazy. I have not fallen in love yet it's my weakness and strength. I don't want to marry and fall in love. Because I'm not able to handle them they used to talk very silly. They are not crazy, they made to make us crazy. 2. Arrange Marriage. Doing arrangement means preparation. It goes with rules and customs if you are old-fashioned or believe in that custom you go through every single step. But nobody is following those rules. We can't stop ourselves to be quiet until the marriage ceremony. We talk on call after the first meeting And take two-three times kisses after fixed marriage we want a separate place to talk. Here everything is under the control of your elders. You know this life is not goes all the time as you think. Enjoy every aspect of life that is life. Either love marriage or arrange marriage. #review#article#marriage

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40244 · 03.12.2025 г., 15:00

Early Roman brides carried a bunch of herbs, like garlic and rosemary 🌿, under their veils to symbolize fidelity ❤️ and fertility 🌱, and to ward off evil 🛡️. These herbs were the precursor to the modern bridal bouquet 💐. @googlefactss#history#marriage#europe [read more...]

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40627 · 05.02.2026 г., 07:01

"Dekichatta kekkon" (できちゃった結婚) or "dekikon" is a Japanese slang from the late 1990s. It means a marriage due to unplanned pregnancy, like a "shotgun wedding," which is a quick marriage to accept an unplanned pregnancy, named after a father using a shotgun to encourage marriage. 📅🤰💍 [Read More] @googlefactss #Japan#Marriage#Slang#Pregnancy#Facts

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40899 · 04.04.2026 г., 22:01

In parts of Togo, wedding ceremonies include the groom’s family performing dances and music. These performances show respect to the bride’s family and celebrate the upcoming marriage. The events often involve drumming, singing, and group dancing as part of the traditional festivities. 💃🥁💍🌍 [Read more] @googlefactss #marriage#culture#tradition#worldfacts#anthropology#africa#weddingrituals#travel If you have ideas or feedback contact us: @Googlefactss_Feedback_bot

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40839 · 21.03.2026 г., 23:01

In certain Thai weddings, couples participate in the Sai Sin ritual, a sacred tradition rooted in Buddhist beliefs. A cotton thread, called Sai Sin, is blessed by monks before the ceremony. The thread is tied around the bride and groom’s wrists or connected around their heads. This ritual symbolizes protection, good luck, and spiritual blessings for the couple. Guests and family may also touch or tie pieces of the thread to pass on their blessings. The Sai Sin connects the newlyweds to their family, community, and the monks who bless them, emphasizing unity and shared support. It is often performed alongside other traditional Thai wedding customs like pouring holy water over the hands of the bride and groom. 🧵👰🤵🇹🇭 [Read more] @googlefactss #marriage#culture#tradition#worldfacts#anthropology#thailand#weddingrituals#travel

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40872 · 28.03.2026 г., 23:01

In some Mexican weddings, couples participate in the Lazo ritual. A large cord or rosary is placed around the bride and groom in a figure-eight shape to symbolize unity and lifelong commitment. 🤍👰🤵🇲🇽 [Read more1] [Read more2] @googlefactss #marriage#culture#tradition#worldfacts#anthropology#mexico#weddingrituals#travel