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

Резултати

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

Пребарај: #globalgovernance

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

@ai_and_law · Post #155 · 02.11.2023 г., 08:04

UN Forms High-level Advisory Body on AI for Global Governance Hello, everybody! The United Nations Secretary-General has launched a multi-stakeholder High-level Advisory Body on Artificial Intelligence. This groundbreaking initiative is set to tap into AI's vast potential for humanity while simultaneously addressing the associated global risks and uncertainties posed by the rapid proliferation of AI technologies. The Advisory Body will encompass up to 38 experts spanning various disciplines, including government, the private sector, and civil society. These experts, hailing from across the globe, bring diverse viewpoints on AI governance to the table. Their aim is to foster collaboration with existing and emerging initiatives alongside international organizations, creating a balanced and comprehensive dialogue on AI governance. The UN's initiative to convene a High-level Advisory Body on AI is a proactive step towards establishing a coherent global framework for AI governance. #UNAIAdvisoryBody#AI#GlobalGovernance

AI & Law

@ai_and_law · Post #318 · 30.05.2024 г., 07:04

Microsoft Advocates for Robust Global AI Governance Microsoft's new publication, “Global Governance: Goals and Lessons for AI,” authored by Brad Smith and Natasha Crampton, explores AI governance by drawing parallels to civil aviation and nuclear power regulation. The report outlines a multi-layered approach involving industry standards, domestic regulation, and international governance to manage AI's global risks and foster inclusive progress. The publication highlights three key goals for international AI governance: ✅Mitigating Global Risks: International collaboration is crucial to address risks associated with AI that transcend national borders. ✅Ensuring Compatibility: Interoperable regulations across countries will be essential for fostering innovation and avoiding fragmented approaches. ✅Promoting Inclusive Growth: International governance should ensure that everyone benefits from the advancements in AI. The publication emphasizes the necessity for robust global governance frameworks to responsibly harness AI’s potential. “Global Governance: Goals and Lessons for AI” is available in print and e-reader formats. #AI#GlobalGovernance#Technology#Microsoft#AIGovernance

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9475 · 04.11.2025 г., 08:13

#Beijing_Review🇨🇳📕[PDF]⬇️ 30 #October2025 #Weekly_Magazines For learning, for free(dom). @backupofmagazines This issue honors the #UnitedNations at 80, calling it a cornerstone of global cooperation. The cover story explores China’s role as a builder of inclusive #GlobalGovernance and its blueprint for shared progress. From women’s empowerment in #Agriculture to structural resilience and economic elasticity, features reveal the new dynamics shaping the #GlobalSouth. Insights on #ChinaUSRelations, the #ChinaMexico partnership, and Hainan’s innovation wave highlight how diplomacy and commerce interconnect. The culture section revives #SilkRoad heritage and Beijing’s ancient treasures. A visionary issue linking history, equality, and collective resilience for a changing world. #Sustainability#Equality#UN80#AsiaVoice#BRInsights

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9490 · 06.11.2025 г., 07:04

#Beijing_Review🇨🇳📕[PDF]⬇️ 6 #November2025 #Weekly_Magazines For learning, for free(dom). @backupofmagazines Beijing Review spotlights China’s #15thFiveYearPlan and its vision for a coordinated, green, and globally inclusive future. The issue unpacks Xi–Trump #Summit diplomacy in Busan, China’s push for #GenderEquality partnerships, and #RCEP as an engine for regional #Integration. Articles explore how strategic planning drives #Sustainability and global development under the banner of #Modernization. From energy transition to cyberspace security, the issue portrays a confident China charting a course for shared growth and stability. #China#GlobalGovernance#Sustainability#FiveYearPlan#RCEP#XiTrumpMeeting#ClimateAction#DigitalFuture#GenderEquality#AsiaPacific