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

Резултати

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

Пребарај: #geopoliticalrisk

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

@CryptoM · Post #65222 · 12.04.2026 г., 04:13

🚀 Iran Nuclear Talks Fail as Tensions Impact Crypto Markets U.S. Vice President Vance announced that after 21 hours of negotiations, no agreement was reached with Iran, which refused to abandon its nuclear weapons program. According to BlockBeats, U.S. President Donald Trump had previously warned that failure in talks would lead to 'total destruction' of Iran. The ongoing conflict has caused volatility in the crypto market for weeks, compounded by tariff disputes, with Bitcoin dropping below $70,000 earlier this month. Analysts had predicted that a successful agreement could push Bitcoin to $80,000, while a breakdown might see it fall to $65,000. On the bullish side, data from on-chain wallets indicate that the largest Bitcoin holders, known as whales, have continued to buy during the peak of geopolitical turmoil rather than sell. Their reasoning is that if the conflict escalates, disrupting oil supplies from the Persian Gulf, rising oil prices and inflation could delay Federal Reserve rate cuts, benefiting scarce assets like Bitcoin and gold. Conversely, Peter Schiff, a gold trader and long-time Bitcoin skeptic, argues that as tensions rise, investors will flee Bitcoin for gold. Schiff predicts a Bitcoin 'collapse,' asserting that gold is the only true safe haven during wartime, and suggests that insiders may be profiting from market fluctuations driven by conflict news. If Trump follows through on his 'total destruction' threat, both stock and crypto markets are likely to experience simultaneous sell-offs. In terms of future developments, Vice President Vance maintained a firm stance at a press conference but did not rule out further negotiations. The Iranian parliamentary speaker demanded a ceasefire in Lebanon and the unfreezing of assets before engaging in formal talks. For Bitcoin traders, the next 72 hours hinge on two critical issues: whether a ceasefire agreement can be sustained and if Trump will escalate the conflict. Meanwhile, whale wallets continue to buy at current prices, indicating that some large investors are betting on stabilization of the situation. #IranNuclearTalks#CryptoMarket#Bitcoin#GeopoliticalRisk#Trump#OilPrices#Inflation#Gold#MarketVolatility#WhaleInvesting#MiddleEastConflict#Lebanon#USPolitics#BTC

Crypto M - Crypto News

@CryptoM · Post #64792 · 10.04.2026 г., 00:06

🚀 Global Economic Concerns Amid Middle East Tensions According to Jin10, a report by China International Capital Corporation (CICC) highlights that since March, concerns over conflicts involving the U.S., Israel, and Iran, along with potential blockages in the Strait of Hormuz, have triggered a market-wide risk aversion. This has led to declines in most asset classes, excluding oil and agricultural products, raising fears of stagflation. CICC acknowledges the undeniable impact of supply shocks, which could potentially slow overall economic growth. However, if the Strait of Hormuz gradually reopens, the geopolitical risks might exacerbate the K-shaped economic divergence, leading to increased investment activity while cooling consumption and employment. In the context of accelerated AI substitution and an inherently cooling labor market, inflation in resource and capital goods is unlikely to create a 'wage-inflation' spiral. From this perspective, CICC suggests that the mainstream narrative of global stagflation might be overstated. The report reiterates the view held since the beginning of the year that, amid an intensified K-shaped economy, liquidity recovery from its trough, and sustained fiscal expansion, the global nominal economic cycle driven by investment is expected to resume its upward trend. This will likely lead to continued rebalancing of global funds across sectors, asset classes, and regions, benefiting a range of physical assets and emerging markets. #GlobalEconomy#MiddleEastTensions#GeopoliticalRisk#Stagflation#SupplyShock#EconomicGrowth#KShapedRecovery#Investment#AIImpact#LaborMarket#Inflation#LiquidityRecovery#FiscalExpansion#EmergingMarkets#AssetAllocation