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

Резултати

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

Пребарај: #gothic

当前筛选 #gothic清除筛选
movies & series 🍿

@images · Post #1573 · 24.06.2024 г., 16:11

🍿 Bill Skarsgård Rises from the Dead in Robert Eggers' 'Nosferatu' 📆Premiere: December 25, 2024 🎭Genre: #Horror · #Gothic 🎬 The highly anticipated remake of 'Nosferatu' directed by Robert Eggers finally unveils its first trailer, promising a terrifying and dark experience. Bill Skarsgård, famous for 'It', completely transforms into Count Orlok, a vampire who haunts a tormented young woman played by Lily-Rose Depp. The director of 'The Lighthouse' and 'The Northman' surprises us once again with his unique gothic vision, using 2,000 real rats in one scene. With a stellar cast that includes Nicholas Hoult and Willem Dafoe, this version promises to redefine classic horror with a modern and chilling twist. 🎥🦇

Velvet Pages | eLibrary 🥂

@bookslibraryofficial · Post #1244 · 25.04.2025 г., 10:45

📖Title : Conjure Wife ✍️Author : Fritz Leiber ⭐️Rating : 3.80/5 (Goodreads) 📆Published : Apr 1, 1943 ———————————————— Summary:In Conjure Wife by Fritz Leiber, Norman Saylor, a rational-minded sociology professor, is shocked to learn that his wife, Tansy, has been secretly practicing witchcraft to protect him from harm and academic sabotage. Believing it's mere superstition, he convinces her to stop. However, as soon as she does, Norman's life begins to unravel—he faces inexplicable misfortunes and threats from unseen forces. Realizing too late that the magical protections were real, Norman must confront a hidden world of witchcraft and rival sorcery. The novel explores themes of gender, power, and the clash between rationalism and the supernatural in modern society. ———————————————— #horror#fantasy#fiction#wicthes#gothic@Bookslibraryofficial@free_novellas

Velvet Pages | eLibrary 🥂

@bookslibraryofficial · Post #1473 · 16.11.2025 г., 15:17

📖Title : Blackthorn ✍️Author : J.T. Geissinger ⭐️Rating : 4.03/5 (Goodreads) 📆Published : Nov 04, 2025 ———————————————— Summary:Blackthorn follows Maven Blackthorn as she returns to her haunted hometown after her grandmother’s funeral—only to discover the body has mysteriously vanished. Caught in a generations-old feud between the Blackthorns and the powerful Croft family, Maven is forced to confront Ronan Croft, her first love and the son of her mother’s suspected killer. Their dangerous chemistry resurfaces as whispers of occult rituals, buried secrets, and horrific betrayals emerge. As Maven digs deeper, she uncovers a terrifying truth that threatens everyone she loves. In a town where the dead refuse to rest, love becomes both a weapon and a deadly curse. ———————————————— #romance#gothic#romantasy#fantasy#paranormal@Bookslibraryofficial@free_novellas@eternalmantra

Welcome🖤 https://x.com/taya_oco/status/1972648026520084951?s=46&t=FAkoqte8XWC8yE4d-Cf0sw Source by pixiv TAYA 原始标签:#女孩子#原创#gothic#长手套#银发#黑色连衣裙 自定义标签:#甜妹 尺寸: 1505x2314 @CosineGallery | 网站 | 3563

Нейросуть | Malikov AI

@neuralsense · Post #540 · 24.07.2025 г., 16:21

Моё первое творческое видео ❤️ Изначально хотела сделать что-нибудь миленькое про эльфов, но наткнулась на красивую мрачную картинку и понеслось... Как вам? Сценарий и картинки: ChatGPT Анимация/монтаж: Kling, Runway, Luma, CapCut #aivideo#kling#runway#luma#chatgpt#gothic

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