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

Резултати

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

Пребарај: #ecosticker

当前筛选 #ecosticker清除筛选
EKOLOG.UZ| ENG

@ekologuzenglish · Post #10870 · 20.12.2025 г., 16:06

Environmental Stickers for Vehicles in Uzbekistan — Free and Voluntary 🚗 📅 On December 19 of this year, the National Committee for Ecology and Climate Change, together with relevant ministries and agencies, held an awareness-raising event at the “Fayzobod” Vehicle Diagnostic Inspection Center located in the Mirabad district of Tashkent. The center operates under the Road Safety Service of the Public Security Department of the Ministry of Internal Affairs. The event was attended by representatives of government bodies, civil society institutions, non-governmental non-profit organizations, political parties, citizens’ self-governance bodies (mahallas), as well as mass media representatives. ♻️ What is an environmental sticker? An environmental sticker is not a fine or a restriction, but an indicator of a vehicle’s environmental condition. It is a symbol of the driver’s responsibility and contribution to clean air and a sustainable future for the country. ❗️Important: Environmental stickers are provided free of charge. 📍 How and to whom are the stickers issued? Environmental stickers are issued: free of charge based on the vehicle owner’s voluntary electronic application; during vehicle registration or re-registration, based on the results of the first free diagnostic inspection. 🚦 Environmental categories of vehicles Within the framework of the system, vehicles will be gradually classified into the following categories: 🟢 “clean” 🟡 “moderate” 🔴 “polluting” The category is determined according to environmental standards, while the color of the sticker reflects the level of the vehicle’s impact on the environment. 🔄 Owners of vehicles classified as “moderate” or “polluting” have the right once a year to undergo a free re-diagnostic inspection, improve the environmental category of their vehicle, and receive a new environmental sticker. 🌱 Why is this important? Despite the measures being taken, air pollution levels in the country remain high. An extremely dry autumn, annual reductions in water resources, as well as emissions from industrial enterprises and vehicles have led to the fact that Tashkent and other settlements are among the regions with high levels of air pollution. 📊 According to medical statistics, in 2024, 11,034.8 cases of respiratory and allergic diseases per 100,000 population were recorded nationwide, a significant proportion of which occurred among children. Air pollution directly affects public health, socio-economic development, and the international image of the country. 📜 Legal framework The “Environmental Transport” system is being introduced in accordance with the Resolution of the Cabinet of Ministers of the Republic of Uzbekistan dated November 28, 2025, No. 750, and will be implemented in stages: 2025–2027 — Tashkent city 2028–2030 — Nukus city and regional centers 2031–2034 — all other regions of the country 🏙 Environmental zones The boundaries of environmental zones will be determined by local Councils of People’s Deputies. Within these zones, the movement of vehicles belonging to the “moderate” and “polluting” categories without an environmental sticker will be restricted. At the same time, social and compensation mechanisms are предусмотрены for residents and workers permanently living or working in these areas. ✨ An environmental sticker is a small step with a big impact. It helps foster environmental awareness, reduce air pollution, and make our cities healthier and more comfortable to live in. 📢 Join us! Get your environmental sticker for free and become part of Uzbekistan’s environmental transformation 🌍💚 #EnvironmentalTransport#EcoSticker#CleanAir#Ecology#Tashkent#Uzbekistan ☘️ Read the latest environmental news on @ekologuz. Subscribe to our page and send your suggestions and feedback via @eklguz_bot.