Заметка начинающим, которые часто сталкиваются с подобной непоняткой.
Ситуация следующая, есть список файлов:
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
#VITE/USDT analysis :
#VITE is currently in an uptrend, consistently making higher lows. The price is bouncing back from the 200-period exponential moving average (EMA) following a retracement to this level. This behavior indicates that the price is expected to maintain its bullish momentum and potentially test higher levels. For a long position, it is advisable to wait for a break above the $0.01365 level before entering the trade.
TF : 4H
Entry : $0.01365
Target : $0.01600
SL : $0.01213
#vue#admin_tempalte#art_design_pro#vite#vue_element_admin#vue3#vue3_admin
Art Design Pro is a free, open-source tool for building admin systems. It uses the latest technology and offers a beautiful interface, making it easy to create high-quality admin systems. You can customize themes and use many features like global search, multi-language support, and rich text editing. This helps developers build systems that are both visually appealing and user-friendly, saving time and effort in development.
https://github.com/Daymychen/art-design-pro
#typescript#cloudflare_kv#cloudflare_pages#cloudflare_workers#drizzle_orm#postgres#remix#tailwindcss#typescript#vite
Supermemory lets you easily save and organize information from websites, PDFs, text, and apps like Google Drive or Notion. You can then chat with your saved memories in natural language to quickly find what you need. It connects with popular AI tools, automatically updates your data, and creates smart knowledge graphs to help you remember and use your information better. This saves you time and effort by keeping all your important content in one place and making it easy to access and search whenever you want. It’s like having a personal assistant for your digital memory.
https://github.com/supermemoryai/supermemory
#typescript#agent#browser_use#computer_use#electron#gui_agents#mcp#mcp_server#vision#vite#vlm
Agent TARS is a powerful tool that helps automate tasks using AI. It integrates with many tools and can handle complex tasks like web scraping and data analysis. This makes it easier to manage workflows and reduces errors. Users can automate tasks in just a few steps, making it very efficient. Agent TARS also supports advanced browser operations and has a user-friendly desktop app, which makes it easy to use for anyone. Overall, it helps users save time and work more efficiently.
https://github.com/bytedance/UI-TARS-desktop
#vue#javascript#music#music_library#music_player#musicplayer#pinia#splayer#vite#vue#vue3
SPlayer is a simple, open-source music player designed mainly for Windows, built with modern web technologies like Vue 3 and Electron. It supports features like login via QR code or phone, daily check-ins, desktop lyrics, local music management, playlist creation, cloud music upload and playback, and even plays some songs without copyright restrictions. It offers light/dark themes, music spectrum visualization, and supports high-quality downloads if you have the right membership. You can deploy it locally or on servers using Docker or Vercel. This player is free for personal use and encourages community contributions, helping you enjoy and organize music easily with a customizable, modern interface.
https://github.com/imsyy/SPlayer
#python#ai#bug_detection#code_audit#code_quality#code_review#developer_tools#devsecops#google_gemini#llm#react#sast#security_scanner#supabase#typescript#vite#vulnerability_scanner#xai
**DeepAudit** is an AI-powered code audit tool using multi-agent collaboration to deeply scan projects for vulnerabilities like SQL injection, XSS, and path traversal. Import code from GitHub/GitLab or paste snippets; agents plan, analyze with RAG knowledge, and verify issues via secure Docker sandbox PoCs, generating PDF reports with fix suggestions. Deploy easily with one Docker command, supports local Ollama models for privacy, and cuts traditional tools' high false positives. **You benefit** by automating secure audits like a pro hacker—saving time, reducing errors, ensuring real exploits are caught, and speeding safe releases without manual hassle.
https://github.com/lintsinghua/DeepAudit
#typescript#app#cap#coss#loom#mac#nextjs#nextjs14#open_source#oss#react#record#screen_capture#screen_recorder#screenshot#solidjs#tauri#tauri_app#typescript#vite
Cap is a free, open-source tool that helps you record and share videos quickly. It's similar to Loom but gives you more control over your recordings. You can use it on both macOS and Windows, making it easy to work with different devices. Cap allows you to store your videos locally or in the cloud, which means you can access them from anywhere. This tool is great for sharing information with teams or clients securely and efficiently.
https://github.com/CapSoftware/Cap