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

Резултати

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

Пребарај: #devblog

当前筛选 #devblog清除筛选
DeckForge Announcement

@deckforge_official · Post #233 · 05.05.2025 г., 08:21

Yama again Last time we talked about what matters to you And today I want to share something that matters to us, developers Soo... 🚂 MEET THE ENGINE 🚂 Choosing an engine for our ambitious game was a challenge DeckForge will eventually be available on many platforms and devices That means that our code has to be easily maintainable, configurable and expandable for different environments We considered several possible solutions, including major game engines We prioritized fast loading, flexibility and cool graphics And after careful evaluation we ended up crafting our own solution on top of the good old three.js library 🤘👵🏻🤘 In terms of rendering - the game is an intricate sandwich of three.js scene wrapped with several layers of html The fun part - three.js is a 3D library with gpu shaders and stuff This enables a lot of visual tools, like VFX and camera shakes Oh, we will make her pretty ✨ Brace yourself, next time i will tell you everything about shaders (👁ˋ _ ˊ 👁) #DeckForge#DevBlog Join the DeckForge Community: 🌐YouTube𝕏Twitter🎮Discord 👉Chat👉Announcements

DeckForge Announcement

@deckforge_official · Post #220 · 20.04.2025 г., 14:08

Hello, future Deck Lords I am Yama - Game Director at DeckForge I represent team LAB behind the development process LAB is a dream team of veterans from different branches of gaming industry and we are very passionate about the game We want to share with you, our players, cool stuff about the development process, listen to your feedback and craft a universe for all of us to enjoy Let's start with some basics 🔵this will be an actual game with gameplay and everything \0/ 🔵we have already produced the alpha version and are moving fast towards beta 🔵multi-platform game, baby! Why are we doing this 🔵we believe the time has come to create a real game product for web3 community 🔵we believe our players want everything a good game should have: gameplay, meta, competitiveness 🔵we believe that we can bring together web3 and web2 communities for their mutual benefit Stay tuned The Forge has just been lit 🔥 #DeckForge#DevBlog Join the DeckForge Community: 🌐YouTube𝕏Twitter 👉Chat👉Announcements

DeckForge Announcement

@deckforge_official · Post #230 · 28.04.2025 г., 14:17

Hello gents Yama here 0/ Let's talk Founder Packs We want you to have fun and profit So we came up with a plan Founder Pack Tiers 🔵 there will be several tiers of Founder Packs (we think 5 is good) 🔵 everyone will be able to claim the lowest tier 🔵 $BOOMS holders - we feel you - depending on your account balance and activity you will be able to claim higher tiers What is inside? 🔵 resources and currency to boost your progress 🔵 powerful items that will give you the edge over competitors 🔵 unique cards and customizations that will not be available through other means 🔵 chance to grab precious NFTs and prizes from our partners Stay tuned for more details #DeckForge#DevBlog#FoundersPack ⸻ Join the DeckForge Community: 🌐YouTube𝕏Twitter 👉Chat👉Announcements