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

Резултати

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

Пребарај: #html

当前筛选 #html清除筛选
GitHub Trends

@githubtrending · Post #15291 · 11.11.2025 г., 15:00

#html The Agent Development Kit (ADK) is an open-source toolkit that helps you build, test, and deploy advanced AI agents easily. It lets you create flexible, multi-agent systems using Python or Java, supports many AI models, and works with different deployment options. ADK offers a rich set of tools, built-in monitoring, and simple integration with Google services, making it easier to develop, debug, and scale your AI applications. This means you can focus on creating smart, efficient agents without worrying about complex setup or compatibility issues. https://github.com/google/adk-docs

Hashtags

GitHub Trends

@githubtrending · Post #15128 · 08.09.2025 г., 11:30

#html You get access to a huge, well-organized collection of 2,053 ready-to-use n8n automation workflows covering 365 different services, all searchable instantly with a super fast, mobile-friendly documentation system. This system offers lightning-fast full-text search, smart categorization by service and use case, and clear, meaningful workflow names, making it easy to find exactly what you need. You can run the documentation locally with simple setup steps, explore workflows by category or complexity, and even download or visualize them. This saves you time and effort in building automations, helps you discover proven workflows quickly, and supports efficient workflow management and customization. https://github.com/Zie619/n8n-workflows

Hashtags

GitHub Trends

@githubtrending · Post #15031 · 05.08.2025 г., 18:30

#html The International Obfuscated C Code Contest (IOCCC) is a programming contest where participants write the most confusing and hard-to-understand C code, often under 512 bytes. It started in 1984 to highlight bad coding styles and show how poor structure can ruin a program. The contest uses satire to teach programmers about C’s tricky parts and the importance of clear coding by showing what not to do. Winning entries are both educational and entertaining, helping you learn subtle C language details while having fun. The contest encourages you to explore and understand complex code, improving your programming skills and appreciation for good style. https://github.com/ioccc-src/winner

Hashtags

GitHub Trends

@githubtrending · Post #14884 · 29.06.2025 г., 13:00

#html You can easily create a secure Octra blockchain wallet by running a simple webserver on your computer. Just clone the wallet generator from GitHub, start the server, and open your browser to generate a new wallet. The tool shows your mnemonic phrase, private and public keys, and address, lets you test signatures, derive addresses for different networks, and automatically saves your wallet file. This helps you safely manage your Octra blockchain assets with full control over your keys and easy access to wallet features without needing complex setups. It’s a user-friendly way to secure and use your Octra wallet locally. https://github.com/octra-labs/wallet-gen

Hashtags

GitHub Trends

@githubtrending · Post #14779 · 03.06.2025 г., 11:30

#html "开往 Travellings" is a project that helps unknown websites get more visitors. It does this by creating a network where users can click a button to randomly visit other participating sites. This project started in 2020 and aims to make the internet more diverse and open. By joining, users can discover new sites and help smaller websites grow. It benefits users by introducing them to new content and supporting lesser-known creators. https://github.com/travellings-link/travellings

Hashtags

Plltxe.

@plltxe · Post #5358 · 04.04.2023 г., 04:46

Is Skia the works-everywhere feature-rich text rendering engine I’ve always been looking for? It seems to work on all sorts of platforms, even on #HTML Canvas with WebAssembly (!) It even used to have particles support, but was sadly removed from 2 months ago. https://skia.org/ 🐘

Hashtags

The Devs

@thedevs · Post #2095 · 29.12.2023 г., 11:02

HTML First, principles to make building web software easier, faster and more inclusive. #article#html @thedevs https://thedevs.link/9MhJrm

123•••910
ПретходнаСтраница 1 од 10Следна