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

Пребарај: #timscott

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

@abmedia_news · Post #24469 · 09.05.2026 г., 00:56

【📜 政策監理|CLARITY 法案 5/14 參議院銀委會 markup 確認:Tim Scott 目標 5/21 前完成】 美國參議院銀行委員會 5/14 上午 10:30 對《數位資產市場 CLARITY 法案》進行逐條審議。委員會主席 Tim Scott 目標 5/21 陣亡將士紀念日休會前完成;繼白宮 5/6 公布 7/4 目標後,立法時程進一步具體化。Tillis-Alsobrooks 穩定幣收益妥協打開推進路徑。 #CLARITYAct#TimScott#穩定幣立法 📍閱讀全文: https://abmedia.io/clarity-act-senate-banking-may-14-markup-tim-scott-may-2026

Venture Village Wall 🦄

@venturevillagewall · Post #3836 · 10.01.2025 г., 07:00

Ethereum Fundamentals Outshine Solana's Growth Fidelity reports fundamental performance of Ethereum is more crucial long-term than Solana's speed and low costs. High developer activity, Total Value Locked (TVL), and stablecoin availability enhance Ethereum's appeal to investors. In contrast, Solana's revenue surge is linked to meme-coin trading, seen as a cyclical trend that will falter in a bear market. Read more: Fidelity on Ethereum vs Solana Additionally, the US Senate Banking Committee preliminarily approves Senator Cynthia Lummis as head of the digital assets subcommittee. This new structure is overseen by Tim Scott. Key members include crypto-friendly legislators Bill Hagerty and Bernie Moreno. Find out more: Senate Approval of Lummis #Ethereum#Solana#DeFi#Crypto#USSenate#DigitalAssets#Investment#Stablecoins#MemeCoins#TVL#Legislation#Blockchain#Finance#TradeFi#Cryptocurrency#Senator#CynthiaLummis#TimScott#BillHagerty#BernieMoreno#Fidelity

Crypto M - Crypto News

@CryptoM · Post #64593 · 09.04.2026 г., 09:45

🚀 U.S. Senate Faces Challenges Over Cryptocurrency Legislation A cryptocurrency bill led by U.S. Senate Banking Committee Chairman Tim Scott is facing bipartisan challenges due to a controversial clause concerning DeFi developer protections. According to ChainCatcher, the clause proposes exemptions for non-custodial software developers who do not control user funds, allowing them to avoid registration as money transmitters or compliance with anti-money laundering regulations. Law enforcement organizations, including the National Sheriffs' Association and the National District Attorneys Association, have expressed concerns to Congress, warning that the clause could weaken efforts to combat financial crime. Senate Judiciary Committee Chairman Chuck Grassley has also voiced similar concerns. The cryptocurrency industry views the clause as central to the bill, with DeFi Education Fund Executive Director Amanda Tuminelli stating that any changes to the text are unacceptable. Democratic Senators Catherine Cortez Masto and Mark Warner are advocating for modifications to the clause. If bipartisan consensus is not reached, the bill may proceed without Democratic support, potentially affecting the required bipartisan majority for a full Senate vote. #USSenate#Cryptocurrency#Legislation#DeFi#FinancialCrime#MoneyLaundering#Bipartisan#TimScott#LawEnforcement#SenateJudiciary#ChuckGrassley#DeFiDeveloperProtections#AntiMoneyLaundering