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

Резултати

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

Пребарај: #regionalstability

当前筛选 #regionalstability清除筛选
Crypto M - Crypto News

@CryptoM · Post #64800 · 10.04.2026 г., 00:36

🚀 Iran Declines Participation in U.S. Peace Talks Without Lebanon Ceasefire Iran has communicated to mediator Pakistan that it will not engage in peace talks with the United States unless a ceasefire is established in Lebanon. According to NS3.AI, this decision underscores Iran's stance on prioritizing regional stability before diplomatic negotiations. The move highlights the complexities of Middle Eastern geopolitics, where ongoing conflicts influence diplomatic interactions. #Iran#US#PeaceTalks#Lebanon#Ceasefire#MiddleEast#Geopolitics#RegionalStability

Crypto M - Crypto News

@CryptoM · Post #64748 · 09.04.2026 г., 17:55

🚀 U.S. President Donald Trump Anticipates Imminent Peace Agreement with Iran U.S. President Donald Trump has conveyed a positive outlook regarding the potential for a peace agreement with Iran. According to NS3.AI, Trump believes that negotiations are progressing favorably, suggesting that a resolution may be reached soon. This development comes amid ongoing diplomatic efforts to address tensions between the two nations. The President's remarks highlight a significant shift in the geopolitical landscape, with implications for international relations and regional stability. #DonaldTrump#Iran#PeaceAgreement#Diplomacy#InternationalRelations#Geopolitics#MiddleEast#Negotiations#RegionalStability

Crypto M - Crypto News

@CryptoM · Post #65390 · 13.04.2026 г., 04:28

🚀 Iranian Lawmaker Deletes Post on U.S. Demands in Nuclear Talks Saeed Mahmoud Nabavian, an Iranian lawmaker engaged in discussions between the U.S. and Iran, recently shared and subsequently removed a social media post detailing three demands from the United States. According to NS3.AI, the deleted message outlined the U.S. requests for joint sharing of benefits from the Strait of Hormuz, the removal of all uranium enriched to 60% from Iran, and a 20-year prohibition on uranium enrichment. The post's removal has sparked speculation about the ongoing negotiations and the potential implications for regional stability. #Iran#US#NuclearTalks#StraitOfHormuz#UraniumEnrichment#MiddleEast#Diplomacy#InternationalRelations#RegionalStability

The 21st meeting of CIS security and intelligence chiefs is taking place in Samarkand. Mirziyoyev called for diplomatic conflict resolution and stronger regional stability. https://yep.uz/en/2025/10/cis-intelligence-chiefs-samarkand-mirziyoyev-diplomatic-resolution/ #Samarkand#CIS#Mirziyoyev#intelligence#security#diplomacy#regionalstability#internationalsecurity

Crypto M - Crypto News

@CryptoM · Post #65058 · 10.04.2026 г., 17:08

🚀 Israel-Hezbollah Conflict Complicates U.S.-Iran Relations The ongoing conflict between Israel and the Iran-backed Lebanese militia Hezbollah is adding complexity to the United States' efforts to resolve its longstanding tensions with Iran. Bloomberg posted on X, highlighting the intricate geopolitical dynamics at play. The hostilities between Israel and Hezbollah have intensified, with both sides engaging in military actions that threaten to escalate further. This situation is complicating U.S. diplomatic strategies aimed at de-escalating tensions with Iran, as Hezbollah's actions are closely linked to Iranian interests in the region. The U.S. has been attempting to negotiate with Iran to address various issues, including nuclear capabilities and regional influence. However, the involvement of Hezbollah, a significant player in the Middle East conflict, poses challenges to these diplomatic efforts. As the situation unfolds, the international community is closely monitoring developments, with concerns about potential broader implications for regional stability. The U.S. continues to navigate these complex relationships, seeking a resolution that addresses both its strategic interests and the security concerns of its allies in the region. #Israel#Hezbollah#USIranRelations#MiddleEastConflict#Geopolitics#USDiplomacy#Iran#Lebanon#RegionalStability#NuclearNegotiations#MilitaryEscalation#InternationalRelations

Crypto M - Crypto News

@CryptoM · Post #65155 · 11.04.2026 г., 13:17

🚀 U.S.–Iran Discussions Begin as Vice President Vance Leads Talks in Islamabad Key Takeaways JD Vance is leading high-stakes talks with Iran in Islamabad.Negotiations aim to stabilize the ceasefire and end the conflict.Talks are indirect and mediated by Pakistan amid deep mistrust.Key issues include Strait of Hormuz, sanctions, and nuclear program. Talks Officially Underway Discussions involving the United States and Iran have officially begun in Islamabad, with JD Vance heading the US delegation. The negotiations are part of a broader effort to extend a fragile ceasefire and potentially move toward a longer-term resolution of the conflict. Pakistan Acting as Mediator The talks are being hosted and mediated by Pakistan, which has played a central role in facilitating communication between both sides. Meetings are taking place under tight security conditionsDelegations are engaging through indirect channels, though direct talks may occurPakistani officials are coordinating between both sides to push toward progress High-Stakes Agenda Key topics under discussion include: Reopening the Strait of Hormuz (critical for global oil supply)Potential sanctions relief for IranLimits on Iran’s nuclear programBroader regional stability and ceasefire enforcement Tensions and Mistrust Remain High Despite the start of talks, major disagreements persist: Iran has set conditions, including halting certain military actionsThe US has maintained a firm stance and warned against delaysBoth sides remain cautious, reflecting deep geopolitical mistrust #USIranTalks#JDVance#Islamabad#PakistanMediating#Ceasefire#StraitOfHormuz#Sanctions#NuclearProgram#RegionalStability#GeopoliticalTensions#DiplomaticNegotiations#HighStakes