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

Пребарај: #metaphysics

当前筛选 #metaphysics清除筛选

EuropeanCulture These days I was asked by some religious fanatic how I define 'European culture'. A very good question on which I had to contemplate for a while, but finally I came up with a definition which I see as sufficient. But first some words on preconditions you should consider when answering this question for yourself: Culture is (in my eyes) the physical manifestation of a racial spirit. This spirit is defined by the genetic composition of a specific race. Because there is a multitude of different European tribes with different admixtures of the same three or four base components (Early Neolithic Farmers/first wave Indo-Europeans, European hunter gatherers, Iron Age invaders/second wave Indo-Europeans/Yamnaya, Neanderthaleans) we have the same foundation but different practices. Additional admixture makes it more complicated so I'll stick with those four. Now that we know that we share the same roots with our European brothers but embody the underlying principle in different ways, let's discuss the definition of 'European culture'! I will focus on the metaphysical aspects, as everything physical derives from these underlying principles. Architecture, art, customs and food are just manifestations. We have to understand that our culture consists of three aspects on the metaphysical level: creation, persistence and destruction. How these three aspects are balanced defines the manifestation of culture. Creation The creation aspect is of utmost importance when it comes to building things, be it a piece of furniture, complex machines or running societies. People of European descent tend to have a strong creation aspect, which can be seen in the vast amount of inventions coming from us. Reacting and adapting to new situations also directly is connected to this aspect. However especially descendants of Homo Erectus tend to be very weak here. Persistence Not just the building of societies is important, but also the maintenance of stable communities needs to be named. The European spirit automatically creates a balance between nature and its people, which reflects in the unique way we care for the environment we live in. Homogenous European societies are also the most stable and prosperous, as we can focus our powers for common goals without being forced to do. Free, cooperating societies are the most successful. Destruction This is not a negative aspect per se, but can be seen as change, ending of one thing and the willpower to start something new. It influences the Faustian spirit of our people. There is a reason why we can be found on every continent! We push the boundaries a bit each time we accomplish something. Our spirit is restless and needs new challenges otherwise it will become blunt and useless. To sum it up: the unique setup of our genetics expresses in the perfect balance of the three metaphysical aspects creation, persistence and destruction. These balanced traits manifest in the physical world and make us builders, explorers, inventors, self-sustained farmers and more. Name another ethnic group which expresses its spirit like we do! Thanks for reading! #metaphysics @EuropeanTribalism

Hashtags

Yukiokhruner

@yukiokhruner · Post #33 · 04.05.2022 г., 17:29

Mi domando da tanto tempo del perché i più parlino dell'amore come se fosse a portata di mano, sono arrivato alla conclusione che é un'illusione necessaria per alleviare l'amarezza della quotidianità. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#illusione#illusion#amore#love#solitudine#loneliness#metafisica#metaphysics

Yukiokhruner

@yukiokhruner · Post #35 · 06.05.2022 г., 17:36

La nettezza urbana: necessaria, sporca, inefficiente e talvolta poetica. #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#metafisica#metaphysics#degrado#decay#nettezzaurbana#sanitation#spazzatura#trash

Crypto M - Crypto News

@CryptoM · Post #64582 · 09.04.2026 г., 09:15

🚀 AI Event to Showcase Diverse Applications in Pop Culture An event titled 'Super Creator Live - Creating Pop Culture with Prompts' is set to take place this Saturday. According to BlockBeats, the event is co-hosted by Beating and West Sea Voice and will feature ten demo works selected from numerous submissions. Participants include developers with deep technical expertise, influential content creators, and professionals from finance, music, and podcast industries. The diverse backgrounds of the creators promise to offer intriguing perspectives on AI's integration into unexpected fields such as gaming, interactive design, sociology, emotional support, and metaphysics. Following the demo presentations, several prominent guests will engage in a roundtable discussion, focusing on the essence of creation and exploring how to define expression in the era of AI. With only two days left until the event, interested individuals are encouraged to register promptly. The event will take place on April 11 at 13:30 UTC+8, with the location details available upon registration. #AI#PopCulture#Event#Creators#Gaming#InteractiveDesign#Sociology#EmotionalSupport#Metaphysics#AIIntegration#Roundtable#Finance#Music#Podcast#Beating#WestSeaVoice#Demo#AIInCreation#Tech#ContentCreators