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

Пребарај: #chuckgrassley

当前筛选 #chuckgrassley清除筛选
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

Reuters: World

@reutersworldchannel · Post #149353 · 14.10.2021 г., 13:16

October 14, 2021: Norway mass killing, Taiwan fire, Big Tech, U.S. Capitol riots, California October 14, 2021: Norway mass killing, Taiwan fire, Big Tech, U.S. Capitol riots, California 1. A 37-year-old Danish citizen who had converted to Islam is suspected of killing five people with a bow-and-arrow and other weapons in the Norwegian town of Kongsberg in a rare incident of mass killing in Norway, police said. 2. A fire in a residential building in the southern Taiwanese city of Kaohsiung has killed 46 people and injured another 41, the government said. 3. A bipartisan group of lawmakers, headed by Democrat Amy Klobuchar and Republican Chuck Grassley, plan to introduce a bill that would bar Big Tech platforms, like Amazon and Google, from favoring their products and services. 4. A congressional panel investigating the deadly Jan. 6 riot at the U.S. Capitol said it has issued a subpoena seeking testimony and records from Jeffrey Clark, a former senior official at the Justice Department who was a proponent of former President Donald Trump's false election fraud claims. 5. California firefighters took advantage of a break in strong winds to get an aircraft aloft and dump retardant on a fast-moving wildfire that was within a half mile of former President Ronald Reagan's ranch, officials said. #Norway #Taiwan #Fire #BigTech #Democrats #Republicans #AmyKlobuchar #ChuckGrassley #UnitedStates #CapitolRiots #Trump #California #Wildfires #RonaldReagan #News #Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖