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

Резултати

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

Пребарај: #greenuniversity

当前筛选 #greenuniversity清除筛选
Green University CA | Official

@centralasian_greenuniversity · Post #461 · 05.12.2025 г., 05:17

December 5 - World Soil Day 🌳Today we celebrate World Soil Day, a global reminder of how important healthy soil is for food security, ecosystems, and our future. 🍀Let’s appreciate the ground beneath our feet — it sustains life more than we realize. #WorldSoilDay#GreenUniversity ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Образование в Узбекистане

@obrazovanie_uzbekistan · Post #2872 · 11.07.2024 г., 13:00

🎓Приём в Green University ещё открыт!🌿 📚Степени бакалавра: Бакалавр (с отличием) Экологический и устойчивый менеджмент Бакалавр (с отличием) Окружающая среда и экономика Бакалавр (с отличием) Экология и государственное управление 🎓Магистерские степени: Магистр (с отличием) Экологическое право Магистр (с отличием) Экологические коммуникации Магистр (с отличием) Устойчивое развитие Магистр (с отличием) Устойчивые финансы 🔄Возможность перевода: продолжить обучение на 2-м курсе Green University Чтобы подать заявку или узнать критерии приема: 📧Электронная почта: [email protected] 📞Телефон: +998555120077 Подайте заявку прямо сейчас:https://greenuniversity.uz/en/apply/main Критерии поступления:https://greenuniversity.uz/en/apply/manual/admission-criteria Центрально-азиатский университет по изучению окружающей среды и изменения климата Green University Формируйте более зеленое будущее вместе с нами! 🌍 Telegram | Instagram #GreenUniversity#Admissions#Sustainability#TransferStudents

Green University CA | Official

@centralasian_greenuniversity · Post #315 · 09.11.2025 г., 09:04

📣Exciting news! 🗓This Tuesday, November 11, Dr. Anna Ubaydullaeva — lecturer at GREEN University, Tashkent, will give a seminar in Rome, Italy (RomaTre) on “Climate Change Law and Sustainable Development in Central Asia: Lessons and Perspectives from Uzbekistan.” 🔜A great opportunity to share Uzbekistan’s experience and vision on climate sustainability with the international community! 🇺🇿🤝🇮🇹 #GREENUniversity#Uzbekistan#ClimateAction#Sustainability ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #1073 · 17.04.2026 г., 10:20

Green University Organized “Youth Day” Events On April 16, in celebration of Youth Day, Green University organized a series of events covering various areas for students and young people. 🖥The program included psychological consultations, English language classes, sports competitions, and the “Zakovat” intellectual game. In addition, a preventive awareness session with representatives of the internal affairs bodies was held, followed by an open Q&A session on legal topics. #GreenUniversity#YouthDay#StudentLeague 👉ReadMore ___________________ Green University’da “Yoshlar kuni” tadbirlari o‘tkazildi 16-aprel “Yoshlar kuni” munosabati bilan Green University’da talabalar va yoshlar uchun turli yo‘nalishlarni qamrab olgan tadbirlar tashkil etildi. 🖥Dastur doirasida psixologik konsultatsiyalar, ingliz tili mashg‘ulotlari, sport musobaqalari hamda “Zakovat” intellektual o‘yini o‘tkazildi. Shuningdek, ichki ishlar organlari vakillari ishtirokida profilaktik uchrashuv va huquqiy mavzudagi ochiq savol-javob sessiyasi tashkil etildi. #GreenUniversity#YoshlarKuni 👉Batafsil ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #670 · 28.01.2026 г., 04:54

January 28 — International Reducing CO₂ Emissions Day 📸👩‍🏫👨‍🏫Every action counts! Today is a reminder that students are not just learners, but future leaders of a more sustainable world. ✔️From saving energy and choosing public transport to supporting green innovations, small daily choices can make a big difference for our planet. 🔼Let’s work together for cleaner air, a healthier environment, and a greener future. The change starts with us. #GreenUniversity#ClimateAction#CO2Reduction#SustainableFuture ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #481 · 05.12.2025 г., 12:26

Law and Ecology Roundtable at Green University 🗓On December 4, 2025, Green University held a high-level Roundtable on Law and Ecology bringing together researchers from leading international institutions to discuss pressing issues at the intersection of environmental governance, ecological transition, and sustainable development. The roundtable featured four expert presentations: 🟠Pauline Couteau (Sciences Po) – introducing the role and research initiatives of Sciences Po in the field of environmental studies; 🟠Dr. Álvaro Artigas Pereira (Sciences Po) – delivering insights on “Confronting Policies to Complexity: Policy Capacity and Development in Shifting Times”; 🟠Tom Wassenaar (CIRAD) – discussing environmental risks and territorial approaches; 🟠Prof. Bénédicte Cenki (University of Montpellier) – presenting on the challenges of mineral resources and the ecological transition, and how to balance energy demands with environmental protection. 🟡The session concluded with an open discussion, allowing students and researchers to engage directly with the speakers. #GreenUniversity#LawAndEcology#ClimateAction#SustainableDevelopment ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #36 · 09.07.2024 г., 04:54

🎓Green University Admissions Still Open!🌿 Join our cutting-edge programs: 📚Bachelor's Degrees: BSc (Hons) Environmental and Sustainable Management BSc (Hons) Environment and Economics BSc (Hons) Ecology and Public Administration 🎓Master's Degrees: MSc (Hons) Environmental Law MSc (Hons) Environmental Communication MSc (Hons) Sustainable Development MSc (Hons) Sustainable Finance 🔄 Transfer Opportunity: Continue in 2nd year at Green University! To apply or for admission criteria: 📧 Email: [email protected] 📞 Call: +99855 512 00 77 Apply now:https://greenuniversity.uz/en/apply/main Admission criteria:https://greenuniversity.uz/en/apply/manual/admission-criteria Shape a greener future with us!🌍 #GreenUniversity#Admissions#Sustainability#TransferStudents

Green University CA | Official

@centralasian_greenuniversity · Post #494 · 09.12.2025 г., 04:43

📸 Highlights from the Experience Sharing Network #GreenUniversity#ExperienceSharingNetwork#Sustainability#YouthLeadership ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #344 · 13.11.2025 г., 07:44

Healthy Planet, Healthy You! ❗️Informative signs on “General Rules and Environmental Protection: Healthy Eating Habits” have been placed around the campus by psychologist Muslima Nabijonova and tutor Shokhrukh Obidov — reminding everyone that caring for nature starts with caring for ourselves #GreenUniversity#EcoLifestyle#HealthyEating#Sustainability ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

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