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 слични објави

Пребарај: #nuland

当前筛选 #nuland清除筛选
BadVolf

@BadvolfNews · Post #546 · 28.02.2023 г., 09:50

🇫🇷Victoria Nuland knew about the far right militias in Ukraine, but concealed the fact - French report. A bloodthirsty regime change initiator, the deaths of many hundreds of thousands started with her 'cookies in Kiev' moment. #Nuland#Ukraine Share and subscribe to American Majority

BadVolf

@BadvolfNews · Post #83 · 19.05.2022 г., 15:11

🇺🇸Actually, that is a really interesting video. Remember how during Senate testimony, Biden and Obama official Victoria Nuland admitted there were biological research labs in Ukraine? Victoria Nuland told Senator Marco Rubio: “Ukraine has biological research facilities which we are now quite concerned Russian troops, Russian forces may be seeking to gain control of.” Nuland said so under oath. Why didn’t Victoria "cookies of freedom" Nuland just say there aren’t any bioweapons? Hint: there are bioweapons. If she would have lied, she would go to jail. So just look, what we have. Here's another document we got from our whistleblower. Read it carefully. So there's a reason why Blinken literally stops her from visiting Russia and answering their questions. Ms. Nuland needs to be questioned again, but this time by a Special Counsel and under the penalty of perjury. Russia and China want their questions to be answered too! #Ukraine#bioweapon#biolab#Nuland Share and subsribe @american_majority

BadVolf

@BadvolfNews · Post #97 · 25.05.2022 г., 20:00

⚡BREAKING⚡ 🇺🇸🇺🇦Nuland-Pyatt Tape Removed From YouTube After 8 Years The smoking gun proving U.S. involvement in the 2014 coup in Kiev has been removed from YouTube after eight years, Consortium news reported. The removal of a video happend just a few days later after the American majority channel published another leaked letter from Nuland's office and this proves its authenticity. It was the most complete version of the leaked conversation between then Assistant Secretary of State Victoria Nuland and Geoffrey Pyatt, the then U.S. ambassador to Ukraine, in which the two discuss who will make up the new government weeks before democratically-elected Ukrainian President Viktor Yanukovych was overthrown in a violent coup on Feb. 21, 2014. The U.S. State Department never denied the authenticity of the video, and even issued an apology to the European Union after Nuland is heard on the tape saying, “Fuck the E.U.” SMELL THE PANIC #Ukraine#bioweapon#biolab#Nuland#leak Share and subsribe @american_majority

The New Southerner

@american_majority · Post #121 · 25.05.2022 г., 20:17

⚡BREAKING⚡ 🇺🇸🇺🇦Nuland-Pyatt Tape Removed From YouTube After 8 Years The smoking gun proving U.S. involvement in the 2014 coup in Kiev has been removed from YouTube after eight years, Consortium news reported. The removal of a video happend just a few days later after the American majority channel published another leaked letter from Nuland's office and this proves its authenticity. It was the most complete version of the leaked conversation between then Assistant Secretary of State Victoria Nuland and Geoffrey Pyatt, the then U.S. ambassador to Ukraine, in which the two discuss who will make up the new government weeks before democratically-elected Ukrainian President Viktor Yanukovych was overthrown in a violent coup on Feb. 21, 2014. The U.S. State Department never denied the authenticity of the video, and even issued an apology to the European Union after Nuland is heard on the tape saying, “Fuck the E.U.” SMELL THE PANIC #Ukraine#bioweapon#biolab#Nuland#leak Share and subsribe @american_majority