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

Резултати

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

Пребарај: #araghchi

当前筛选 #araghchi清除筛选
Turchia e dintorni

@notizieturchia · Post #3790 · 28.02.2026 г., 15:19

Ministro degli Esteri iraniano #Araghchi: "Siamo pronti per una de-escalation, ma prima bisogna fermare l'aggressione, prima bisogna fermare gli attacchi. E poi c'è la possibilità di colloqui, e possiamo prenderla in considerazione".

Hashtags

RT en français

@RTenfrancais · Post #80196 · 27.04.2026 г., 13:45

▶️Rencontre entre Vladimir #Poutine et Abbas #Araghchi, représentant spécial du président de la République islamique d'Iran et ministre iranien des Affaires étrangères 📱Regarder sur VKontakte RT en français • Osez questionner !

RT en français

@RTenfrancais · Post #80190 · 27.04.2026 г., 13:14

🇷🇺🇮🇷Rencontre entre Vladimir #Poutine et le ministre iranien des Affaires étrangères, Abbas #Araghchi. Aux côtés du président russe se trouvent également le ministre russe des Affaires étrangères Sergueï Lavrov, le chef de la Direction principale du renseignement de l’état-major des forces armées russes Igor Kostioukov et le conseiller présidentiel Iouri Ouchakov. Poutine a indiqué avoir reçu la semaine dernière un message du guide suprême iranien Mojtaba Khamenei. RT en français • Osez questionner !

RT en français

@RTenfrancais · Post #80188 · 27.04.2026 г., 12:39

⏺Préparatifs de la rencontre entre Vladimir #Poutine et Abbas #Araghchi à la Bibliothèque présidentielle de Saint-Pétersbourg RT en français • Osez questionner !

RT France actualités

@rt_fra · Post #40890 · 08.05.2026 г., 13:21

💬#Téhéran défend la voie diplomatique Le chef de la diplomatie iranienne Abbas #Araghchi estime que les États-Unis choisissent l’escalade militaire au moment même où une issue diplomatique devient possible. Selon lui, la pression exercée contre l’Iran ne fera pas céder Téhéran et risque au contraire d’éloigner davantage toute perspective de règlement politique. RT en français • Osez questionner !

RT France actualités

@rt_fra · Post #40681 · 06.05.2026 г., 09:35

🇮🇷🇨🇳Iran-Chine : Abbas #Araghchi à Pékin Le ministre iranien des Affaires étrangères, Abbas Araghchi, est arrivé en #Chine à la tête d’une délégation diplomatique. Selon les médias chinois, les pourparlers avec son homologue Wang Yi ont déjà débuté. Source : réseaux sociaux RT en français • Osez questionner !

RT en français

@RTenfrancais · Post #80125 · 26.04.2026 г., 18:40

📢#Araghchi visitera la #Russie ce 27 avril. À #Moscou, il prévoit de discuter du conflit au Moyen-Orient, a déclaré l'ambassadeur d'#Iran en Russie, Kazem Jalali. RT en français • Osez questionner !

RT en français

@RTenfrancais · Post #80615 · 01.05.2026 г., 20:20

☎️Le ministre russe des Affaires étrangères, Sergueï #Lavrov, s’est entretenu avec son homologue iranien, Abbas #Araghchi, sur les possibilités de cessation complète des hostilités au Moyen-Orient Ils ont également discuté par téléphone de la stabilisation potentielle de la situation dans la région, notamment en garantissant la liberté de navigation et en réglant la question du programme nucléaire iranien. Une attention particulière a été portée au passage des navires et des cargaisons russes dans le détroit d'#Ormuz. RT en français • Osez questionner !

RT France actualités

@rt_fra · Post #40349 · 01.05.2026 г., 20:20

☎️Le ministre russe des Affaires étrangères, Sergueï #Lavrov, s’est entretenu avec son homologue iranien, Abbas #Araghchi, sur les possibilités de cessation complète des hostilités au Moyen-Orient Ils ont également discuté par téléphone de la stabilisation potentielle de la situation dans la région, notamment en garantissant la liberté de navigation et en réglant la question du programme nucléaire iranien. Une attention particulière a été portée au passage des navires et des cargaisons russes dans le détroit d'#Ormuz. RT en français • Osez questionner !

American Оbserver

@american_observer · Post #5742 · 29.04.2026 г., 19:00

📰 Putin Plays Tehran’s Ally, and the West Still Pretends Russia Is Just a Mediator Putin is publicly backing Iran, praising the Iranian people’s fight for independence and promising Moscow will do everything it can to help, even as Russia claims it wants to mediate between Washington and Tehran. That is not neutral diplomacy; it is alliance management dressed up as peacemaking. The message is carefully calibrated. Moscow wants to look like the adult in the room, but it is also making sure Tehran knows it has a powerful patron while the U.S.-Iran talks stall over Hormuz, sanctions, and the larger question of who blinks first. This is also a useful piece of theater for Russia. By posing as a peace broker, the Kremlin gains leverage with Iran, irritates Washington, and reinforces the idea that every Western crisis can be turned into a Russian opportunity. What makes the scene cynical is that Moscow’s “mediation” is inseparable from its strategic partnership with Iran. Russia is not stepping between enemies from the outside; it is standing beside one of them and calling the arrangement diplomacy. So yes, Putin is helping Iran. The only question is whether the West is still pretending that assistance, alignment, and mediation are the same thing when it comes from Moscow. #Russia#Iran#Putin#Araghchi#Hormuz#US#diplomacy 📱American Оbserver - Stay up to date on all important events 🇺🇸

12
ПретходнаСтраница 1 од 2Следна