Заметка начинающим, которые часто сталкиваются с подобной непоняткой.
Ситуация следующая, есть список файлов:
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
#csharp
The Model Context Protocol (MCP) is an open standard that lets AI models connect easily and securely to external data sources and tools, like business systems or cloud services. It acts like a universal adapter, enabling AI to access the right context and data to perform tasks accurately and efficiently. Microsoft offers many MCP servers that link AI with services such as Azure DevOps, SQL databases, Microsoft 365, and more, allowing AI to interact naturally with your data and workflows. This helps you get smarter AI assistance, better automation, and easier integration across your tools.
https://github.com/microsoft/mcp
#csharp
RunCat 365 is a fun and cute app that shows a running cat animation on your Windows taskbar. The cat’s running speed changes based on your computer’s CPU usage, so you can easily see how hard your computer is working just by watching the cat. It’s made for Windows only and is built with C# and .NET 9.0. This app adds a playful and useful visual indicator to your taskbar, making it easier and more enjoyable to monitor your PC’s performance at a glance. It’s free and open-source, with many users enjoying its charm and functionality[4].
https://github.com/Kyome22/RunCat365
#csharp
The eShop reference application is a sample e-commerce website built using .NET 9 and a services-based architecture. It helps developers learn how to create modern web applications. To use it, you need to install .NET 9 SDK, Docker, and possibly Visual Studio or Visual Studio Code. This application is beneficial because it provides a real-world example of how to structure and deploy a complex web application, making it easier for developers to understand and implement similar projects.
https://github.com/dotnet/eShop
#csharp
JSC “KDB Bank Uzbekistan” is looking for Middle or High level of S/W designer with C#, C Programming
Job description:
Software design
· Experience to design new software for multi users using middleware like Apache Kafka
External Interface module development, maintenance and support
· Receiving and analyzing user’s request
· Coding and Test
· Implementation and documentation
· Supporting of the banking system users
Professional requirements:
· Experience of development tool: Visual Studio, GCC or any C compiler
· Experience of Database environment (Oracle)
· At least 2-3 years of experience in the field of programming in C/C++ & C#
· Time management (in order to meet deadlines set by the management)
· English Speaking (should be able to execute instruction and verbal report by English)
· Good written and spoken Russian
Working conditions:
Salary based on interview results, depends on skills and knowledge from 12 mln.soums to 22 mln. soums
Working hours 5/2 from 9:00 - 18:00
Office is located in the center of Tashkent
Benefits:
Medical insurance
Incentive payments for Holidays
Performance bonus
Material assistances for special events (marriage, birth of child and etc.)
Mortgage loan, overdraft facility
Teambuilding
Contacts:
Nozima Yakubova, Head of HR dpt.
telegram: @nozimayakubova
email: [email protected]
More information you can get from our web site: https://kdb.uz/en
#vakansiya#dotnet#csharp
Davr Bank Middle/Senior .NET dasturchi izlamoqda
Talablar:
• C# / .NET Framework
• ASP.NET, REST API
• WCF, Windows services
• Oracle
• JSON/XML
Qo'shimcha ma'lumotlar:
• Maosh - 500$ dan 2000$ gacha
• Ish vaqti - 9:00 dan 18:00 gacha
• Hudud - Toshkent shaxri
Resume yuboring:Nodir
.NET Uzbekistan Community
______
Telegram | Instagram | Youtube
✅ Завтра
Шахматный клиент-сервер на C#. Часть 2. Шахматная доска + фигуры. Unity3D.
📅 28 февраля / 19:00 (время МСК) / онлайн
💵 Бесплатно
📝 Регистрация тут: https://goo.gl/P8dT1K
План вебинара:
~ Вступление. Установка Unity3D.
~ Размещение доски с фигурами.
~ Перемещение мышкой.
~ Фиксация хода.
~ Взятие фигур.
~ Проверка правил.
Для участия в вебинаре обязательна регистрация. На емейл, который вы укажете в регистрационной форме, 28 февраля 2018 года будет отправлено письмо-приглашение со ссылкой на трансляцию.
#Unity3D#Csharp#online#онлайн