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

Пребарај: #nasdaq100

当前筛选 #nasdaq100清除筛选
NEWS 鏈新聞-ABMedia

@abmedia_news · Post #24345 · 04.05.2026 г., 11:01

【💰 交易市場|為搶進 SpaceX、OpenAI 與 Anthropic IPO 熱潮,那斯達克與標普放寬標準】 #SpaceX#OpenAI#Nasdaq100 標普與那斯達克 5 月修改規則,縮短 SpaceX 等巨頭入選指數的等待期。 那斯達克增設快軌機制,市值前 40 名企業掛牌 15 天即可空降成為成分股。市場擔憂被動資金過早湧入,導致股價在定價前遭到嚴重扭曲。 📍閱讀全文: https://abmedia.io/nasdaq-sp500-listing-rules-relaxed 📍 訂閱鏈新聞頻道:https://linktr.ee/abmedia.io

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 #64545 · 09.04.2026 г., 07:14

🚀 Whale Adjusts Investment Strategy Across Major Markets On April 9, a significant investor, known for substantial positions in three major markets, closed all long positions in WTICRUDE and BRENTOIL, according to BlockBeats. Previously, the combined holdings in these oils exceeded $14.1 million, resulting in a loss of over $3.9 million upon closure. Following this, the investor opened a short position in WTICRUDE at an average price of $92.3, with a current scale of $9.3 million and a liquidation price of $117.6. This adjustment has led to the following main positions across the three markets: In U.S. stocks, the investor holds long positions in the Nasdaq 100 and S&P 500, with a scale of $38.1 million and an unrealized profit of $430,000. In the cryptocurrency market, the investor maintains a long position in Bitcoin, with a scale of $12.05 million at an average price of $6,540, resulting in an unrealized profit of $30,000. In commodities, the investor's short position in WTI crude oil stands at $9.3 million, with an unrealized loss of $290,000. The address associated with these transactions is 0x8af700ba841f30e0a3fcb0ee4c4a9d223e1efa05. #Investment#MarketStrategy#WTICrude#BrentOil#USStocks#Nasdaq100#SP500#Bitcoin#Cryptocurrency#Commodities#Trading#Blockchain#BlockBeats#BTC

PRICE ACTION EXPERT

@priceactionexpert · Post #7905 · 23.11.2024 г., 08:14

https://x.com/priceactiongann/status/1830819785975955483 #nifty#geometry#banknifty New Course Book! ✅Market movements through the lens of advanced Geometric concepts. ✅Multidimensional and Spherical Time concepts of Trading with our upcoming course (book), ✅This innovative book dives deep into the concept of time-related trading, blending advanced geometric principles with practical markets Exploring Triangles, Squares, and Circles. ❤️🙏❤️ #stocks#stockmarket#gann#trading#time#gold#silver#xauusd#SPX500#DowJones#NASDAQ100

PRICE ACTION EXPERT

@priceactionexpert · Post #7723 · 03.09.2024 г., 04:08

https://x.com/priceactiongann/status/1830819785975955483 #nifty#geometry#banknifty New Course Book! ✅Market movements through the lens of advanced Geometric concepts. ✅Multidimensional and Spherical Time concepts of Trading with our upcoming course (book), ✅This innovative book dives deep into the concept of time-related trading, blending advanced geometric principles with practical markets Exploring Triangles, Squares, and Circles. ❤️🙏❤️ #stocks#stockmarket#gann#trading#time#gold#silver#xauusd#SPX500#DowJones#NASDAQ100