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

Резултати

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

Пребарај: #goldprices

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

@CryptoM · Post #65364 · 13.04.2026 г., 02:43

🚀 PRECIOUS METALS | Gold Prices in Uncertain Range Amid Middle East Tensions Gold prices are currently positioned in the middle of a fluctuating range, with short-term predictions remaining uncertain. According to Jin10, the market is bracing for a potential escalation in Middle East conflicts, which has led to gold prices opening lower during the Asian trading session. Analysts suggest that the price of gold may continue to hover within this range, making it difficult to predict future movements in the short term. #GoldPrices#MiddleEastTensions#PreciousMetals#MarketUncertainty#Gold#TradingSession

Crypto M - Crypto News

@CryptoM · Post #64515 · 09.04.2026 г., 05:30

🚀 PRECIOUS METALS | Chinese Gold Jewelry Prices Drop Significantly Gold jewelry prices in China have seen a notable decline today, according to Jin10. Several brands have reduced their prices by approximately 25 yuan compared to yesterday. The current prices are mostly in the range of 1,445 yuan to 1,450 yuan per gram. #preciousmetals#gold#chinagold#goldprices#jewelryprices#marketnews

Crypto M - Crypto News

@CryptoM · Post #65377 · 13.04.2026 г., 03:06

🚀 PRECIOUS METALS | Chinese Gold Jewelry Prices Remain Stable On April 13, Jin10 reported that the prices of gold jewelry in China have shown little change compared to last Friday. According to Jin10, several brands have maintained their pricing within the range of 1,445 yuan per gram to 1,450 yuan per gram. #preciousmetals#gold#goldjewelry#China#goldprices#stableprices#Jin10

Crypto M - Crypto News

@CryptoM · Post #65321 · 12.04.2026 г., 22:56

🚀 PRECIOUS METALS | Gold Prices Drop 2% Following U.S. Naval Blockade Order Gold prices fell by 2% to approximately $4,650 per ounce after U.S. President Donald Trump ordered a naval blockade of the Strait of Hormuz. According to Jin10, this decision came after peace talks between the U.S. and Iran failed over the weekend in Pakistan, unable to convert a fragile ceasefire into lasting peace following six weeks of conflict in the Middle East. The surge in energy prices has heightened inflation risks, increasing the likelihood that central banks may delay rate cuts or even raise rates. This development poses a bearish factor for non-yielding gold, which typically benefits when borrowing costs are lower. #Gold#PreciousMetals#GoldPrices#USPolitics#NavalBlockade#StraitOfHormuz#Inflation#EnergyPrices#InterestRates#MiddleEastConflict

Crypto M - Crypto News

@CryptoM · Post #64787 · 09.04.2026 г., 23:54

🚀 PRECIOUS METALS | Gold Prices Decline Amid Ongoing Inflation Worries Gold prices have experienced a slight decline as concerns over persistent inflation continue to influence market sentiment. Wall Street Journal (Markets) posted on X that the precious metal's value is being affected by ongoing fears of inflation, which remain a significant factor for investors. The market is closely monitoring economic indicators and central bank policies that could impact inflation rates. As these concerns persist, gold's appeal as a hedge against inflation is being tested, leading to fluctuations in its price. Investors are advised to stay informed about economic developments that may affect the precious metals market. #Gold#PreciousMetals#Inflation#MarketTrends#Investing#EconomicIndicators#CentralBank#FinancialMarkets#HedgeAgainstInflation#GoldPrices

Crypto M - Crypto News

@CryptoM · Post #65396 · 13.04.2026 г., 04:55

🚀 PRECIOUS METALS | Swiss Bank Reacquires Gold Amid Market Recovery Swiss Bank has resumed purchasing gold after previously reducing its holdings due to market downturns triggered by the Iran war. According to Jin10, the bank had significantly cut its gold holdings from about 10% to 3% of its portfolio. Despite the challenges, Swiss Bank maintains a positive long-term outlook for gold and is gradually reintegrating it into client investment portfolios. Since the onset of the conflict, gold prices have dropped sharply due to concerns over higher interest rates and liquidity constraints. The bank's gold holdings have now increased to approximately 6% of its portfolio. Swiss Bank anticipates that gold prices will rise to $6,000 per ounce by the end of this year, driven by structural demand factors such as central bank purchases, fiscal deficit concerns, and geopolitical tensions. #PreciousMetals#Gold#SwissBank#MarketRecovery#Investment#Geopolitics#CentralBank#FiscalDeficit#GoldPrices#PortfolioManagement

Crypto M - Crypto News

@CryptoM · Post #65333 · 13.04.2026 г., 00:13

🚀 PRECIOUS METALS | U.S. Inflation and Fed Rate Cut Expectations Impact Gold Prices On April 13, Jin10 reported that a research note from CITIC Securities highlighted the significant rise in U.S. overall inflation for March, driven by soaring oil prices, while core inflation remained moderate. According to Jin10, CITIC Securities anticipates minimal risk of secondary inflation in the U.S. and suggests that April's CPI may continue to show elevated growth due to compensatory increases in rental inflation. If oil prices decline slowly, U.S. CPI could remain above 3% year-on-year for the rest of the year. CITIC Securities also forecasts a 25 basis point rate cut by the Federal Reserve within the year, which may lead to a weaker U.S. dollar in the near term. This scenario could create liquidity-driven recovery opportunities for gold prices. Additionally, U.S. equities might benefit from improved risk appetite, while U.S. Treasury yields may lack sufficient downward momentum due to economic fundamentals. #PreciousMetals#USInflation#FedRateCut#GoldPrices#CITICSecurities#OilPrices#CoreInflation#CPI#USDollar#USEquities#USTreasuryYields