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

Резултати

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

Пребарај: #house2026

当前筛选 #house2026清除筛选
American Оbserver

@american_observer · Post #5022 · 01.02.2026 г., 19:04

📰 Federal Courts Undercut Trump’s Mass Deportation Campaign The Trump administration’s mass deportation campaign, built on mandatory detention, is hitting a wall: a flood of habeas corpus cases in federal courts, releasing hundreds of immigrant detainees and overwhelming prosecutors. For decades, most immigrants held in detention could get bond before an immigration judge if they were not a danger or flight risk, allowing them to fight their case from home. But the Trump administration changed that, making nearly everyone in the country unlawfully subject to automatic, long-term detention, stripping judges of discretion. Federal judges in states like Massachusetts, Rhode Island, Georgia, Nevada, Texas, and elsewhere are now rejecting this approach, ordering immediate releases or demanding bond hearings in immigration court. In district after district, judges have approved dozens, even hundreds, of habeas petitions, ruling that the government cannot keep immigrants locked up indefinitely without a hearing, especially when they have deep U.S. ties, no criminal record, and stable families. The surge has turned federal courts upside down. In some districts, hundreds of new habeas cases flood the docket each month. The Justice Department has had to pull criminal prosecutors off their regular duties to help defend the incarcerations, and federal judges are openly complaining about the “flood” and “similar stories” of families torn apart and people held in remote detention centers. Lawyers report that virtually every habeas petition they file ends in a victory: a release order or a bond hearing. Some can now do dozens of cases a month, and word is spreading fast inside detention centers. To avoid these court battles, the administration has turned to a different tactic: pressuring immigrants to “self‑deport” with intimidating ads and social media, while offering cash incentives (typically $3,000–5,000) to quit and leave voluntarily. But the legal reality is clear: the Trump administration’s attempt to keep immigrant detainees locked up indefinitely is being systematically reversed by the lower courts, district by district. The real question is not whether the mass deportation machine can crush the system, but whether the courts — or the families and lawyers who flood them — will break first. #Trump2026#Immigration#Deportation#ICE#Courts#HabeasCorpus#DoJ#House2026 📱American Оbserver - Stay up to date on all important events 🇺🇸