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

Резултати

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

Пребарај: #russianbeauties

当前筛选 #russianbeauties清除筛选
Learn RCRussian🤍💙❤️

@learnRCRussian · Post #6104 · 28.01.2026 г., 13:00

🇷🇺Some Russian winter spirit for you! 🎵 🔻Улетай на крыльях ветра by Евгения Сотникова (Fly Away on the Wings of the Wind) is a segment of the vivid ballet scene Polovtsian Dances from the most famous work by A. Borodin — the opera Prince Igor (1875). Video: elizabet_crow (tik tok) #Russian_culture #Russianbeauties 🟠RCR | Support | Boost

Learn RCRussian🤍💙❤️

@learnrcrussian · Post #4369 · 18.03.2025 г., 18:51

Mydear Russian language learners! I often write about beautiful Russian women and beauty contests held in Russia. And now you have an opportunity to be in the jury! One of the subscribers of @learnRCRussian, a beautiful Russian girl Alena (see the photo, isn't she a beauty?), is a participant in the 10th season of the All-Russian beauty contest "Ты уникальная" (You Are Unique). 🟠Her number is 🔴 🔴. The final will be held on March 21st, and also launched is the long-awaited online voting, for which there will be a separate nomination and one of the main crowns: 🔴Miss PHOTO. Voting conditions are simple: 1. Subscribe (very important!): http://vk.com/tu.penza And https://www.instagram.com/tu.penza?igsh=MWxteHJxNzh2Z.. 2. Like the post with number 🔴 🔴 3. Leave a comment The participant with the most likes wins. PS The account is private. You'll get access as soon as you subscribe to the channel. This is a mandatory condition to avoid cheating. 🔴Please support her! Thank you everyone! Natalie with ❤️ #admins_letter #Russianbeauties

Learn RCRussian🤍💙❤️

@learnrcrussian · Post #4104 · 24.01.2025 г., 13:00

In order to become a continuation of the northern lights in the Murmansk region, a Muscovite woman created an unusual luminescent dress. 🔻Natalya Zakharova found suitable luminous paints and created the outfit with her own hands. 🔻The dress became a continuation of the magnificent northern lights on the Kola Peninsula. 🔻Before the photoshoot, the dress had to be charged with light. On the Kola Peninsula at the end of November, the duration of daylight hours is almost zero, and it is not possible to charge naturally. 🔻The girl did not specify how long the shooting itself lasted, but admitted that she "froze to the bone." Photos: Наталья Захарова (vk) #around_Russia #brief_and_interesting #Russianbeauties 😎RCRussian | Support | Boost

Learn RCRussian🤍💙❤️

@learnRCRussian · Post #6012 · 11.01.2026 г., 14:40

The Internet is full of AI Snow maidens, but a creative team from Orenburg just dropped the ultimate response — a stunning music video with REAL girls. 🇷🇺Снегурочка (снегурочки) (femin.noun) [sni-gu-rach-ka (sni-gu-rach-ki)] Snow Maiden(s) 🔻Forget algorithms, this is about roots. Everything is authentically Russian and locally crafted: 🔸Shawls and outfits by Orenburg down-knitters 🔸Kokoshniks by a local designer 🔸All beauties from Orenburg "We are promoting what is our own, what is native," is their powerful motto. So, which version warms your heart more: the AI or this real, living beauty? 🔻Kokoshnik 🔻Orenburg shawls 🔻#Russianbeauties #AI #russian_culture 🟠RCR | Support | Boost

12
ПретходнаСтраница 1 од 2Следна