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

Пребарај: #oilfutures

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

@CryptoM · Post #65284 · 12.04.2026 г., 14:26

🚀 Oil Futures Surge as Trump Orders Naval Blockade of Strait of Hormuz Oil futures on Hyperliquid experienced a significant increase following U.S. President Donald Trump's directive to implement a naval blockade of the Strait of Hormuz. According to NS3.AI, West Texas Intermediate (WTI) crude oil perpetual futures surged by 7%, reaching $96.40, while Brent futures rose by 6% to $96. The trading volume for WTI futures hit $1.53 billion, ranking it as the third-most-traded instrument on the platform, following Bitcoin (BTC) and Ethereum (ETH). Emergency reserve releases have been compensating for a daily shortfall of approximately 4.5 to 5 million barrels, but this buffer is approaching its limit. #OilFutures#Trump#NavalBlockade#StraitOfHormuz#WTI#Brent#CrudeOil#EmergencyReserves#Hyperliquid#BTC#ETH

Crypto M - Crypto News

@CryptoM · Post #65223 · 12.04.2026 г., 04:14

🚀 Sky Co-Founder Rune Faces Losses in Leveraged Oil and S&P 500 Positions Sky co-founder Rune's leveraged positions have recently experienced significant losses. According to Odaily, data from Hyperbot indicates that Rune's sevenfold leveraged short position on the Nasdaq 100 was closed 16 hours ago. Currently, he holds long positions valued at approximately $518,000, including a 20-fold leveraged long position in WTI crude oil futures and a sevenfold leveraged position in Brent oil. Additionally, Rune maintains a 20-fold leveraged short position on the S&P 500, valued at $159,000. At present, all of Rune's positions are in a loss state, with the total value dropping to around $678,000, reflecting a floating loss of approximately $61,000 and an investment return rate of -22.68%. Rune initially entered these positions last month when oil prices were rising, achieving a floating profit exceeding $1 million. However, recent fluctuations and declines in oil prices have turned these positions from profit to loss. #Sky#Rune#LeveragedTrading#OilFutures#SP500#Nasdaq100#FinancialLoss#WTICrude#BrentOil#Investing#SKY

Crypto M - Crypto News

@CryptoM · Post #64472 · 09.04.2026 г., 01:47

🚀 Unusual Oil Market Activity Precedes U.S.-Iran Ceasefire Announcement On April 9, unusual trading activity occurred in the oil market just hours before U.S. President Donald Trump announced a ceasefire agreement with Iran. According to BlockBeats, at 19:45 GMT on Tuesday, investors unexpectedly sold 8,600 lots of Brent and U.S. oil futures during a non-active trading period, amounting to approximately $950 million. Less than three hours later, Trump officially announced a two-week ceasefire with Iran. This news caused oil futures to plummet by about 15% at Wednesday's opening, falling below the $100 mark. The strategic short positions resulted in significant profits within hours. This incident is not isolated; on March 23, similar unusual trading occurred 15 minutes before Trump announced a delay in striking Iranian energy facilities, leading to a 15% drop in oil prices. Since the escalation of U.S.-Iran tensions, daily oil trading volumes have doubled to millions of lots. Congressman Ritchie Torres has formally requested the SEC and CFTC to investigate these "suspicious" trades. Torres emphasized the need to examine the accounts involved due to the trades' speed, scale, and structure. Currently, CME and SEC have declined to comment, while CFTC previously stated it is "monitoring" market anomalies. #OilMarket#USIran#Ceasefire#TradingAnomalies#OilFutures#MarketManipulation#SEC#CFTC#BrentCrude#EnergyNews