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

Резултати

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

Пребарај: #strategicreserve

当前筛选 #strategicreserve清除筛选
以太坊区块链新闻| ETH 以太币圈热瓜

@ethereumglobalnews · Post #1636 · 29.12.2025 г., 05:28

📊👀 SharpLink Gaming (SBET) •目標進度:目前已完成收購目標的 14.3%,最終目標是持有 5% 的 $ETH 流通供應量。 ETH Reserve 持續增持,其 mNAV 目前為 0.75,顯示該企業正以極其激進的方式將 ETH 納入資產負債表。 #ETH#StrategicReserve #以太坊#链上观察#区块链 ——— 👇⭐️👇 🤣 🥲👇 資源搜索 🖲️👆

Venture Village Wall 🦄

@venturevillagewall · Post #4072 · 05.02.2025 г., 10:00

Major Updates on Bitcoin and Ethereum 🔗 *Roman Storm secures legal funding for trial* with support from Paradigm and Vitalik Buterin! Details here: Leviathan News. 🔗 David Sacks confirmed evaluating a *national Bitcoin reserve* is a priority for Trump's Digital Assets Task Force. BTC is touted a *superior store of value*. Regulations on crypto incoming within six months! 🔗 XRP Ledger briefly halted due to validation issues but self-healed. More info: Coindesk. 🔗 Hong Kong weighs *Bitcoin as a strategic reserve*, urging to accelerate feasibility studies. Insights here: Wu Blockchain News. 🔗 Ethereum's *supply rises* back to pre-merge levels due to Dencun upgrade, signaling inflation. More: The Block. 🔗 U.S. to consider Bitcoin reserve as an essential economic security asset; institutional adoption underway! #Bitcoin#BTC#Ethereum#ETH#Crypto#Legal#Funding#XRP#Regulations#HongKong#StrategicReserve#DigitalAssets#AI#VC#MicroStrategy#Inflation#Securities#DeFi#Stocks#Bonds#ETFs

Venture Village Wall 🦄

@venturevillagewall · Post #4329 · 07.03.2025 г., 10:00

U.S. Bitcoin Reserve Announced by Trump President Trump establishes a U.S. Strategic Bitcoin Reserve using forfeited assets, ceasing prior sales of confiscated Bitcoin. Current U.S. holdings include about 200,000 BTC, with only 86,000 BTC available for reserves. Crypto markets react as Bitcoin price drops $5,000. The reserve aims to act as a digital savings medium without taxpayer costs. For further details, read the full story here: Axios. #Bitcoin#Crypto#VC#Trump#Reserve#Bitfinex#Blockchain#Government#Assets#CryptoMarket#DigitalAssets#StrategicReserve#Forfeited#Volatility#MarketReaction#InvestorNews#USeconomy

Venture Village Wall 🦄

@venturevillagewall · Post #3908 · 17.01.2025 г., 22:00

Crypto Advocate Ramaswamy Eyes Ohio Governance Vivek Ramaswamy, a crypto proponent and new leader of the Department of Government Efficiency (DOGE), is set to announce his candidacy for Ohio governor soon. He advocates for unrestricted use of self-hosted crypto wallets. In other news, TON DeFi lender EVAA Protocol raised $2.5 million in a private token sale. 🤝 Meanwhile, Massachusetts Senator Peter Durant introduced legislation for a Strategic #Bitcoin Reserve. 💼 Notably, Q4 2024 saw a significant rebound in crypto VC investment, totaling $3.5 billion, a 46% increase from the previous quarter. 📈 In crypto price updates, Bitcoin recently reached $106,000 with a 55% rise over the past 90 days. Coinbase publicly supports the US Government's Strategic Bitcoin Reserve initiative. For more details: - Ramaswamy's Candidacy - EVAA Protocol Fundraiser - Crypto VC Investment Data - Coinbase's Support for Bitcoin Reserve #Crypto#VC#Bitcoin#TON#DeFi#EVAA#Investment#Government#Candidacy#Ohio#Ramaswamy#Coinbase#Regulation#SelfHostedWallets#StrategicReserve#Blockchain#Finance#CryptoMarket#CryptoNews

Venture Village Wall 🦄

@venturevillagewall · Post #4328 · 07.03.2025 г., 07:00

Trump Establishes Strategic Bitcoin Reserve Former President Trump has signed an order to create a strategic Bitcoin reserve in the U.S., based on approximately 200,000 BTC confiscated by the government. This reserve will serve as a savings asset, not intended for sale, acting as a digital Fort Knox. Meanwhile, analysts indicate that governments may follow the U.S. lead, reducing the likelihood of Bitcoin bans from regulators. Post-announcement, Bitcoin saw a price drop from $91,000 to $85,000 but has since recovered to $88,000. No altcoins are currently included in the reserve plans. Full details here: Reuters #Bitcoin#crypto#Trumpr#US#Blockchain#Finance#Regulation#Assets#DigitalCurrency#Investments#Savings#Market#Trading#Reserves#Government#FTX#Securities#FortKnox#Economy#PriceDrop#StrategicReserve

Venture Village Wall 🦄

@venturevillagewall · Post #3825 · 09.01.2025 г., 01:00

Public Companies and El Salvador Boost Bitcoin Two U.S. companies enhance Bitcoin holdings: Thumzup Media invests $1M, shifting 90% of assets to Bitcoin and considering Bitcoin payments for workers. KULR Technology acquires $21M in Bitcoin, totaling $42M. El Salvador buys an additional 11 Bitcoin for its reserves. Meanwhile, Oklahoma proposes SB 325 to allow Bitcoin payments and seeks a payment processor by 2026. Decrypt | Oklahoma Bill #Bitcoin#ElSalvador#PublicCompanies#Investment#Crypto#Thumzup#KULR#Finance#PaymentProcessing#Legislation#Oklahoma#TaxGuidance#DigitalAssets#Reserves#StrategicReserve#Blockchain#Assets#CryptoNews#SB325#VC