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

Пребарај: #copyrightlaws

当前筛选 #copyrightlaws清除筛选
AI & Law

@ai_and_law · Post #203 · 29.12.2023 г., 08:04

NY Times Takes On OpenAI and Microsoft Over Copyright Infringement Hello everybody! The New York Times has filed a lawsuit against OpenAI and Microsoft for alleged copyright infringement. This marks the first time a major American media organization has taken legal action against creators of prominent AI platforms, including ChatGPT. The lawsuit, filed in Federal District Court in Manhattan, claims that millions of articles from The Times were used without authorization to train automated chatbots, putting the media giant in direct competition with AI systems. The heart of the matter lies in the contention that the intellectual property of The New York Times was utilized to train AI models, specifically chatbots, that now serve as alternative sources of information. The lawsuit does not specify a monetary demand but emphasizes the responsibility of the defendants to be held accountable for "billions of dollars in statutory and actual damages." The legal action calls for the destruction of any chatbot models and training data incorporating copyrighted material from The Times. The lawsuit reveals that The Times initiated discussions with Microsoft and OpenAI in April to address concerns about the unauthorized use of its intellectual property. These talks, aimed at finding an amicable resolution, including a potential commercial agreement, did not result in a resolution. The legal battle could set a precedent for the legal boundaries surrounding generative AI technologies, particularly regarding the use of copyrighted materials. As concerns about the unlicensed use of intellectual property by AI systems grow, this case joins a series of legal actions within the tech industry. The outcome of such lawsuits may have far-reaching implications, not only for The New York Times but for the broader media landscape. #AILaw#NYTimes#OpenAI#Microsoft#ChatGPT#CopyrightLaws#AIEthics