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

Резултати

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

Пребарај: #talabalarhayoti

当前筛选 #talabalarhayoti清除筛选

Universitetimizda Harvest Festivali bo‘lib o‘tdi. Bugun Al-Xorazmiy universitetida mehnat, baraka va qadriyatlar ifodasi Harvest Festivali ko‘tarinki ruhda o‘tkazildi. 🍇 Talabalarimiz tomonidan tayyorlangan milliy taomlar, ijodiy ishlanmalar, jonli musiqalar va qiziqarli ko‘ngilochar dasturlar festivalga yanada fayz qo‘shdi. 🎶 ✨ Professor-o‘qituvchilarimiz ham talabalar bilan birga turli o‘yinlarda faol ishtirok etib, bayramga yanada samimiyat bag‘ishladilar. Tadbir do‘stlik, birdamlik va ezgu qadriyatlarimizni mustahkamlashga xizmat qilishi shubhasiz. 🔁English ➖➖➖➖➖➖➖ #HarvestFestival#TalabalarHayoti Bizning ijtimoiy tarmoqlarimiz: Veb-sayt | Telegram | Instagram | Facebook | Aloqa-bot

Green University CA | Official

@centralasian_greenuniversity · Post #1000 · 06.04.2026 г., 14:47

Youth Day Celebrations Held at Green University ⚪️A series of events dedicated to Youth Day was held at Green University, bringing students together for a day of learning and engagement. 🧑‍🎓The program included a motivation workshop, English classes for local children, a “Book Brain” presentation, the “Zakovat” intellectual game, and a specialized workshop on waste management for law students. The day concluded with sports activities promoting a healthy lifestyle. #GreenUniversity#YouthDay#StudentLife#Zakovat#SustainableDevelopment#ActiveYouth 👉ReadMore ________________________ Green University’da Yoshlar kuniga bag‘ishlangan tadbirlar o‘tkazildi ⚪️Green University’da Yoshlar kuni munosabati bilan bir qator tadbirlar tashkil etilib, talabalar uchun mazmunli va samarali kun tashkil etildi. 🧑‍🎓Dastur doirasida motivatsiya bo‘yicha trening, mahalliy bolalar uchun ingliz tili mashg‘ulotlari, “Book Brain” loyihasi taqdimoti, “Zakovat” intellektual o‘yini hamda huquqshunoslik yo‘nalishi talabalari uchun chiqindilarni boshqarish mavzusida maxsus seminar o‘tkazildi. Kun yakunida sog‘lom turmush tarzini targ‘ib qiluvchi sport tadbirlari tashkil etildi. #GreenUniversity#YoshlarKuni#TalabalarHayoti#Zakovat#BarqarorRivojlanish#FaolYoshlar 👉Batafsil ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #1061 · 13.04.2026 г., 08:19

Highlights from the Youth Day at Green University. #GreenUniversity#YouthDay#StudentLeague#TeamSpirit#Leadership __________________________ Green University Yoshkar kunidan lavhalar. #GreenUniversity#YoshlarKuni#TalabalarLigasi#TalabalarHayoti#Jamoaviylik#Liderlik ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #1049 · 10.04.2026 г., 13:10

📌On April 9, Green University actively celebrated Youth Day with a dynamic and engaging program that brought together students, faculty, and administration. 🗣️Throughout the day, participants took part in a wide range of activities — from educational workshops and intellectual games to open lectures and cultural events. The atmosphere was vibrant, reflecting the energy, enthusiasm, and ambition of the youth. A special highlight was the opening of the Student League sports competitions, where the university rector, Dr. Bakhtiyor Pulatov personally took part alongside students. His participation made the event even more inspiring, strengthening the spirit of unity, teamwork, and friendly competition. ✅Youth Day at Green University once again proved that the university is not only a center of education, but also a space where students actively develop, engage, and succeed together. #GreenUniversity#YouthDay#StudentLeague#StudentLife#TeamSpirit#Leadership 👉ReadMore __________________________ 📌9-aprel kuni Green University'da Yoshlar kuni keng qamrovli va mazmunli dastur asosida faol tarzda nishonlandi. Tadbirlar davomida talabalar, professor-o‘qituvchilar hamda universitet rahbariyati birlashdi. 🗣️Kun davomida ishtirokchilar turli ta’limiy seminarlar, intellektual o‘yinlar, ochiq ma’ruzalar va madaniy tadbirlarda faol qatnashdilar. Muhit yoshlarga xos energiya, ishtiyoq va intilishlarga boy bo‘ldi. Tadbirning eng esda qolarli biri Talabalar ligasi sport musobaqalarining ochilish marosimi bo‘ldi. Unda universitet rektori, professor Baxtiyor Pulatov ham talabalar bilan bir qatorda ishtirok etib, o‘zining faol ishtiroki orqali birlik, jamoaviylik va sog‘lom raqobat muhitini yanada mustahkamladi. ✔️Green University'da Yoshlar kuni yana bir bor universitet nafaqat ta’lim maskani, balki talabalar har tomonlama rivojlanadigan, faol ishtirok etadigan va birgalikda yuksaladigan muhit ekanini namoyon etdi. #GreenUniversity#YoshlarKuni#TalabalarLigasi#TalabalarHayoti#Jamoaviylik#Liderlik 👉Batafsil ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #1016 · 07.04.2026 г., 05:45

📢OPEN LECTURE ANNOUNCEMENT Dear students, professors, and university staff! Join us on April 9, 2026, at 14:00 for an engaging open lecture by Sherzod Ziyoyev, Senior Lecturer of the Department of Foreign Languages, historian and political scientist. 🎓Topic: “Strategic Importance of the Modern Silk Road Projects and Transit Routes for Eurasian Land Countries” 🌍The lecture will explore the history, evolution, and current relevance of the modern Silk Roads — a must-attend for anyone interested in geopolitics, history, and regional development. 🗣Languages: Uzbek & English 📍Venue: University Conference Hall 💪Don’t miss this opportunity to gain valuable insights! #OpenLecture#SilkRoad#Eurasia#Geopolitics#GreenUniversity#StudentLife _________________________ 📢OCHIQ MA’RUZA E’LONI Hurmatli talabalar, professor-o‘qituvchilar va universitet xodimlari! Sizlarni 2026-yil 9-aprel kuni soat 14:00 da bo‘lib o‘tadigan ochiq ma’ruzaga taklif qilamiz. Ma’ruzachi — Xorijiy tillar kafedrasi katta o‘qituvchisi, tarixchi va siyosatshunos Sherzod Ziyoyev. 🎓Mavzu: “Zamonaviy Ipak yo‘li loyihalari va tranzit yo‘nalishlarining Yevroosiyo quruqlik mamlakatlari uchun strategik ahamiyati” 🌍Ma’ruza davomida zamonaviy Ipak yo‘lining tarixi, rivojlanishi va bugungi kundagi ahamiyati haqida so‘z yuritiladi. Ushbu mavzuga qiziqqan barcha ishtirok etishga taklif etiladi. 🗣Tillar: o‘zbek va ingliz 📍Manzil: Universitet konferensiya zali 💪Foydali bilimlar olish imkoniyatini qo‘ldan boy bermang! #OchiqMaruza#IpakYoli#Yevroosiyo#Geosiyosat#GreenUniversity#TalabalarHayoti ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube