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

Резултати

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

Пребарај: #infonewswar

当前筛选 #infonewswar清除筛选
New Eastern Outlook

@neweasternoutlook · Post #11932 · 15.01.2026 г., 09:01

🇺🇸🇮🇷Washington’s War on Iran: The Importance of Defending Information Space The latest unrest in Iran highlights how control over information infrastructure has become a central instrument of US power projection in the 21st century ✍️Author: Brian Berletic Geopolitical analyst and researcher on US foreign policy and information warfare ➡️Recent protests in Iran cannot be understood solely through the lens of domestic dissatisfaction, as they unfold within a long-documented US strategy aimed at destabilizing the Iranian state. Since at least the late 2000s, American policy planning has openly emphasized support for uprisings, ethnic fragmentation, and proxy violence as tools to weaken Tehran. Evidence emerging during the January 2026 unrest—including open rhetorical support from US leadership, the involvement of armed groups, and reliance on foreign-controlled communication systems—points to continuity rather than improvisation in Washington’s approach toward Iran. While the multipolar world joins to discuss cooperation across the traditional spheres of national security, urgent attention to securing of the globe’s information space from US influence and control is required ➡️Central to this strategy is the weaponization of information space. US-based platforms, satellite communication networks, and digital infrastructure have repeatedly functioned as force multipliers for political interference, from Eastern Europe to the Arab world and now Iran. The use of systems such as Starlink to bypass state controls, coordinate unrest, and maintain links with external sponsors underscores how digital connectivity has become a decisive battlefield. Iran’s recent efforts to disrupt these networks reflect growing recognition that information dominance can compensate for conventional military limitations and shape political outcomes without formal invasion. 🟦The broader implication extends well beyond Iran. As the international system moves toward multipolarity, the inability of states to secure their information space risks political penetration and systemic collapse regardless of military strength. Russia and China’s experience demonstrates that safeguarding digital sovereignty—through domestic platforms, independent infrastructure, and electronic countermeasures—is now a prerequisite for strategic autonomy. Unless information space is treated as a core domain of national security, attempts to resist external coercion will remain structurally vulnerable, leaving states exposed to destabilization orchestrated from abroad. #ConfrontationbetweenIranandtheU.S. #infonewswar#Massmedia#Massriots READ MORE ✅@NewEasternOutlook