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

Резултати

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

Пребарај: #maritimetraffic

当前筛选 #maritimetraffic清除筛选
International News

@intnewsagency · Post #9205 · 05.04.2026 г., 06:32

Oil Market Balance May Return by April An increase in traffic through the Strait of Hormuz by 5–6 tankers daily could restore market balance. Despite the London insurance market halt, up to 42% of the fleet under Liberia, Marshall Islands, Malta, and Bahamas flags are shifting to Chinese and Indian state guarantees. Panama and Singapore’s flexible fleets adapt faster, while Iran and Hong Kong’s “shadow fleet” bypass sanctions and remain active. #oil#market#sanctions#Russia#maritimetraffic The main news of Russia and the world ishere.

Crypto M - Crypto News

@CryptoM · Post #64934 · 10.04.2026 г., 10:55

🚀 Increase in Ship Traffic Through Strait of Hormuz Observed On April 10, the number of ships passing through the Strait of Hormuz increased to nine, according to data from shipping intelligence company Kpler. According to BlockBeats, this marks a rise from the previous day's count of five vessels, although it remains below the broader normalized levels. #Shipping#StraitOfHormuz#MaritimeTraffic#Kpler#BlockBeats

Crypto M - Crypto News

@CryptoM · Post #65394 · 13.04.2026 г., 04:52

🚀 Strait of Hormuz Traffic Halts Following U.S. Maritime Blockade All maritime traffic through the Strait of Hormuz has reportedly ceased after U.S. President Donald Trump declared a maritime blockade via social media. According to NS3.AI, information from British sources, as reported by CCTV News, indicated that the blockade had been in place for several hours. While traffic was still feasible on the 12th, at least two vessels attempting to exit the strait reversed course. Tanker traffic had seen a slight uptick on the 11th before declining on the 12th. #StraitOfHormuz#MaritimeBlockade#USPresident#DonaldTrump#TankerTraffic#CCTVNews#NS3AI#MaritimeTraffic

Crypto M - Crypto News

@CryptoM · Post #64927 · 10.04.2026 г., 10:19

🚀 Iran Considers Bitcoin Toll for Ships in Strait of Hormuz Iran is contemplating a new toll system for ships passing through the Strait of Hormuz, potentially requiring a $1-per-barrel fee payable in Bitcoin. According to NS3.AI, Hamid Hosseini, spokesperson for Iran’s Oil, Gas, and Petrochemical Products Exporters’ Union, indicated that this move could significantly impact maritime traffic. Arkham, a maritime analytics firm, estimates that a typical cargo ship carrying around 3 million barrels would face a payment of approximately $3 million in Bitcoin. Martin Kelly, head of advisory at maritime intelligence group EOS Risk, noted that this regulation could reduce the number of ships allowed to pass through the strait to 10–15 per day, a sharp decrease from the current average of about 135 ships. #Iran#Bitcoin#Toll#StraitOfHormuz#Shipping#MaritimeTraffic#Oil#Cryptocurrency#Petrochemical#MaritimeRegulation#BTC

Crypto M - Crypto News

@CryptoM · Post #65316 · 12.04.2026 г., 22:22

🚀 WTI Crude Oil Rises 10% Amid U.S.-Iran Peace Talks Stalemate WTI crude oil experienced a significant intraday increase of 10%, reaching $105.33 per barrel, following the conclusion of the initial round of U.S.-Iran peace talks in Islamabad, which ended without an agreement. According to NS3.AI, the U.S. Central Command announced plans to block all maritime traffic to and from Iranian ports starting at 2:00 p.m. UTC on April 13. The U.S. military clarified that vessels traveling through the Strait of Hormuz to non-Iranian ports will not encounter any restrictions. #WTI#CrudeOil#USIranPeaceTalks#MaritimeTraffic#Iran#StraitOfHormuz#USTechnology#NS3AI#CentralCommand#OilPrices