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

Резултати

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

Пребарај: #nama

当前筛选 #nama清除筛选
Borkena

@borkena · Post #6191 · 21.04.2026 г., 13:07

በሲቪል ሰርቪስ ከ150 በላይ የሀሰተኛ የትምርህርት ማስረጃ ተገኘ መባሉ ፤ በመንግስት ደጋፊነት የሚተቸው አብን መዋቅራዊ በደል ድርሷል ማለቱ እና ሌሎች ዜናዎች ፡፡ https://youtu.be/y4-9eSmywW8#Ethiopia#News#Amharic#EthiopianNews#fakecredential#education#NAMA

Addis Standard

@addisstandardeng · Post #21510 · 24.02.2026 г., 09:10

News: #NAMA, #ADPM welcome House of Federation decision to hold elections in five districts outside #Tigray oversight The National Movement of #Amhara (NAMA) and the Amhara Democratic Force Movement (ADPM) have welcomed a recent decision by the House of #Federation to conduct elections in five districts outside the oversight of the Tigray regional authorities, pending the resolution of their constitutional status. In separate statements issued following emergency executive meetings, both organisations said the decision provides a legal response to long-standing questions of political participation and identity in the “contested” electoral districts, while also raising concerns about its implementation. NAMA said it respects the decision, which followed communication between the House of Federation and #NEBE, & described it as consistent with the spirit of the Pretoria Agreement. For its part, ADPM described the House’s move as “the beginning of historical.... Read more: https://addisstandard.com/?p=55369

Addis Standard

@addisstandardeng · Post #21287 · 03.02.2026 г., 07:48

#Ethiopia: MP Abebaw challenges peace talks with splinter armed groups Member of Parliament Dr. Abebaw Desalew of the National Movement of Amhara (#NaMA) has questioned Prime Minister #Abiy Ahmed over the federal government’s approach to peace negotiations and regional security, warning that talks with what he described as “splinter groups” have failed to bring tangible improvements on the ground. Dr. Abebaw raised the concerns during the 10th Regular Session of the 5th Year of the 6th Term of the House of Peoples’ Representatives (#HoPR), where MPs questioned the Prime Minister on the government’s six-month performance report. He said Ethiopia continues to face a pervasive lack of peace, particularly in conflict-affected regions including #Amhara, #Oromia, #Tigray, and #Gambella, while noting that serious human rights violations are also reported in regions without active armed conflict. “Even in areas not experiencing open conflict, members from the... Read more: https://addisstandard.com/?p=54927

📺 AnimeAction++

@animeactioz · Post #3981 · 25.04.2024 г., 16:21

Saijaku Tamer wa Gomihiroi no Tabi o Hajimemashita aka The Weakest Tamer Began a Journey to Pick Up Trash | 最弱テイマーはゴミ拾いの旅を始めました 📅Año 2024 País🇯🇵Japón 🎥Dirección#ShigeyasuYamauchi, #NaokiHoriuchi 📄Guion Katsuhiro Takayama. 📚Novelas#Honobonoru500, #Nama 🎼Música Kujira Yumemi 🎬Productora Studio Massket Género#SeriedeTV#Animación#Drama#Fantástico#Naturaleza Reparto | Trailer | Sinopsis ⏱Duración 23min. 🖥Resolución 720x400 🗣Idioma Japonés Subtítulos Latino Episodio01 - 02 - 03 - 04 - 05 - 06 - 07 - 08 - 09 - 10 - 11 - 12 Suscripción a este Anime 👉🏻Aquí Índice de Animaciones 👉🏻Aquí