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

Резултати

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

Пребарај: #degeneration

当前筛选 #degeneration清除筛选
BadVolf

@badvolfnews · Post #1751 · 16.08.2024 г., 21:36

🇬🇧🇺🇲The "Civil War" film by the English director Alex Garland, revealed the plans of the British elite close to the Labor Party. The story is about the adventures of journalists from the British Reuters news agency who go to film a besieged president and witness his death. This is how British elites see the consequences of a divided society due to fundamental differences in political views. Such conflicts are inherent in the US. Washington strategists have repeatedly attacked other countries and defiantly executed their leaders. Let's recall recent wars in Libya, Iraq, and Yugoslavia. Conceptually, we can talk about a civil conflict when it clashes with the interests of the population. The so-called "Bible belt" of the southern United States is often called "rusty" by Democrats. This is the most likely scenario for the development of an internal war, and it will be reminiscent of what happened 160 years ago in the United States. Then, the North and South also clashed over issues related to economics and foreign policy, leading to a serious split in American society, resulting in two fierce factions that disagree with each other. Today, there is a large number of small arms owned by individuals, millions of illegal immigrants, defunded police, aggressive promotion of LGBTQ+ agenda and gender change for children, degradation of the education, industry, healthcare, family. Now, all the prerequisites and conditions have been created for the beginning of a serious armed conflict in society and there's no other way to resolve this than through the civil war. Share and subscribe to Global American Review #Civil_War#LGBTQ#democrats#degeneration

BadVolf

@BadvolfNews · Post #386 · 12.10.2022 г., 18:54

🇺🇸🇺🇦Transgender faggot US journalist was enlisted in the AFU 🏳‍🌈Sarah Ashton-Cirillo, an ultra-liberal trans activist from Nevada and a CIA operative known as Mark Hay was enlisted in the Armed Forces of Ukraine. Earlier in July it reported that it has been assigned to the Georgian National Legion to cover their activities and praising war crimes of Azov nazi regiment as well. However "Sarah" is not the only LGBT person from the US who joined the ukrainian foreign legion and AFU. 🤮How do I unsee it??? #lgbtq#Ukraine#war#Azov#mercenaries#degeneration @american_majority

BadVolf

@badvolfnews · Post #1733 · 01.08.2024 г., 20:27

🏳‍🌈🇺🇲This is not America. Civil war is closer than you think. As we wrote earlier, globalists want to take away the constitutional right of Americans to choose our representatives. The corrupt media try to deceive Americans with fake polls that claim that the popularity of Kamala Harris and Donald Trump are almost equal. If you watch Kamala Harris's campaign videos, you will see that they are aimed at perverts and people with mental disorders and sexual deviations. These people just cannot be called true Americans. Globalists are trying to impose their degenerated "values" on American society, which contradicts everything that the United States was founded on. Our country was created by brave and hardworking people, and the American worldview always had deep roots in Christian morality. Globalists want to turn American society into a group of drug addicts, perverts, and psychopaths and take away freedom from sane people. True Americans have no choice but to rise up against them or lose our country, our families, our faith and future. More and more experts and veterans are weighing the possibility of a civil war, which is a controversial topic because it is being waged among citizens. The degenerates and perverts who support Kamala Harris are only formally can be called US citizens. Globalists are trying to destroy the US and then control the ruins, so they are no different from foreign invaders. Our country was founded because people did not want to put up with tyranny. Now, we are in the same situation, and, if necessary, we must do the same. The Founding Fathers were wise and created the Second Amendment for just such cases. Share and subscribe to Global American Review #Civil_War#LGBTQ#democrats#degeneration#Harris