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

Резултати

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

Пребарај: #aigenerated

当前筛选 #aigenerated清除筛选
Custom Emoji Packs

@CustomEmojiPacks · Post #879 · 09.06.2025 г., 22:20

We've brought back the ❤️ reaction and removed the 💫 option. We originally added the star just for fun, but it started to feel unfair - it was appearing on messages that included packs from other people. Even though the donations it generated were minimal and insignificant to us, I still felt bad about it. Anyway, I want to clarify what's been happening with this channel lately. 📰 A few months ago, Telegram placed restrictions on my account for no apparent reason - I wasn't allowed to post in public groups due to some "illegal content". It took me a while to realize that our community group had disappeared too. I'll admit it, our moderation wasn't the best, but we tried to block and remove spam, crypto scams, and anything related to drugs, porn etc, but in the end, our group ended up being deleted. I reached out to some Telegram volunteers, and after a few weeks I was unbanned. They told me I should’ve enabled the new aggressive anti-spam feature, so if you manage a large community, I strongly recommend turning it on. That way, a few troublemakers won’t end up causing problems for everyone. 🚨 That said, technology is evolving at an exponential rate, and with the arrival of AI generated emojis, we also want to evolve this channel into something new. Right now, you can generate an emoji on iOS or certain websites in just a few seconds, which takes away the magic of designing a set from scratch with vector graphics and countless cups of coffee. We still believe in the secret art of emoji creation, but it's fading faster and faster. That's why we're adding the ability to direct message us using the latest Telegram feature, so that you can share your packs, tell us your story and promote your own work - and request collaborations, too. We’ll review each submission, allowing you, in a way, to give us direct post suggestions, resulting in more frequent posts and better management, without the risk of creating another group just to get banned again. We have more ideas for oh how to evolve this community, but we also want to hear yours. At this point, we think the channel needs a new #aigenerated hashtag for emoji packs made with AI tools like ChatGPT or websites such as emojis.com - one of the most advanced AI emoji generators right now (not sponsored, by the way). So, keep creating incredible art in every form. Use AI to push the boundaries of what the human mind can do, without replacing it. Find the right balance, blending AI-generated ideas with your own artistic vision and creativity. That, I believe, must be the right way to create and communicate without getting replaced by technology in future generations. 🚀

Hashtags

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