TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #241 · 5 мај

Можно ли в Python создавать бинарные файлы? Конечно можно. Для этого в Python есть следующие инструменты: ▫️ тип данных bytes и bytearray ▫️ открытие файла в режиме wb (write binary) или rb (read binary) ▫️ модуль struct Про модуль struct поговорим в первую очередь. Файл в формате JSON или Yaml внутри себя содержит разметку данных. Всегда можно определить где список начался а где закончился. Где записана строка а где словарь. То есть формат записи данных содержит в себе элементы разметки данных. В binary-файле данные не имеют визуальной разметки. Это просто байты, записанные один за другим. Правила записи и чтения находятся вне файла. Модуль struct как раз и помогает с организацией данных в таком файле с помощью определения форматов записи для разных частей файла. Модуль struct преобразует Python-объекты в массив байт, готовый к записи в файл и имеющий определённый вид. Для этого всегда следует указывать формат преобразования (или, как оно здесь называется - запаковки). Формат нужен для того, чтобы выделить достаточное количество байт для записи конкретного типа объекта. В последствии с помощью того же формата будет производиться чтение. При этом следует помнить что мы говорим о типах языка С а не Python. Именно формат определяет, что записано в конкретном месте файла, число, строка или что-то еще. Вот какие токены формата у нас есть. Помимо этого, первым символом можно указать порядок байтов. На разных системах одни и те же типы данных могут записываться по-разному, поэтому желательно указать конкретный способ из доступных. Если этого не сделать, то используется символ '@', то есть нативный для текущей системы. В строке формата мы пишем в каком порядке и какие типы собираемся преобразовать в байты. Запакуем в байты простое число, токен "i". >>> import struct >>> struct.pack('=i', 10) b'\n\x00\x00\x00' Теперь несколько float, при этом нужно передавать элементы не массивом а последовательностью аргументов. >>> struct.pack('=fff', 1.0, 2.5, 4.1) b'\x00\x00\x80?\x00\x00 @33\x83@' Вместо нескольких токенов можно просто указать нужное количество элементов перед одним токеном, результат будет тот же. >>> struct.pack('=3f', 1.0, 2.5, 4.1) b'\x00\x00\x80?\x00\x00 @33\x83@' Теперь запакуем разные типы >>> data = struct.pack('=fiQ', 1.0, 4, 100500) я запаковал типы float, int и unsigned long long (очень большой int, на 8 байт) b'\x00\x00\x80?\x04\x00\x00...' Распаковка происходит аналогично, но нужно указать тот же формат, который использовался при запаковке. Результат возвращается всегда в виде кортежа. >>> struct.unpack('=fiQ', data) (1.0, 4, 100500) Как видите, ничего страшного! #lib#basic

Hashtags

Резултати

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

Пребарај: #ailiteracy

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

@ai_and_law · Post #694 · 04.11.2025 г., 08:04

🇳🇱Netherlands' DPA Iissues Guide on Building AI Literacy The Netherlands' data protection authority, Autoriteit Persoonsgegevens, published guidance on developing AI literacy. The AP said AI literacy is critical for developing and deploying responsible AI and algorithms. The guide contains information on legal obligations and offers practical examples for implementing the AP's AI action plan, which is updated periodically. #AILiteracy

Hashtags

AI & Law

@ai_and_law · Post #581 · 30.05.2025 г., 07:04

🇪🇺AI Literacy Is Now a Legal Requirement in the EU: How it Works? As of February 2, 2025, Article 4 of the EU AI Act is in force—and with it, a new legal obligation: AI literacy is no longer optional. Providers and deployers of AI systems must ensure that their personnel, and anyone handling AI systems on their behalf, have sufficient understanding of how these systems function, what risks they carry, and how they interact with the people affected by them. The European AI Office has just released detailed Q&A guidance to clarify what this means in practice. It addresses the definition of “AI literacy,” how to assess adequate knowledge levels based on staff education, experience, and use context, and how enforcement will be handled. This is a significant compliance shift—especially for companies deploying AI in sensitive sectors. Training and governance functions will now need to be legally auditable. #AIAct#AILiteracy#AICompliance#AIGovernance

AI & Law

@ai_and_law · Post #768 · 19.02.2026 г., 08:04

🇺🇸U.S. Department of Labor Launches Federal AI Literacy Framework The U.S. Department of Labor has introduced the United States’ first federal-level AI literacy framework, a voluntary initiative aimed at guiding AI literacy programs across government, the public workforce, and education systems. The framework defines AI literacy as a foundational set of competencies enabling responsible use and evaluation of AI technologies, with a primary focus on generative AI as a core workplace tool. It is intended as a baseline understanding rather than specialized training for AI developers. Designed for broad application, the framework encourages tailored programs for different roles and contexts. It outlines benefits for workers (independent skill-building and adaptation to AI-enabled environments), employers (responsible deployment and workforce transition), and education providers (curriculum design and competency assessment). Although nonbinding, it is expected to influence private-sector training initiatives in the U.S. and abroad. The document emphasizes that AI literacy requirements will evolve with technological change, labor market developments, and implementation feedback. #AIRegulation#AILiteracy#GenerativeAI#PublicPolicy

AI & Law

@ai_and_law · Post #795 · 30.03.2026 г., 07:04

🇺🇸U.S. Department of Labor Launches “Make America AI-Ready” Initiative The U.S. Department of Labor announced the “Make America AI-Ready” initiative, a free AI literacy course designed to provide workers with foundational AI skills. The program delivers training via text messages, allowing users to complete the course in seven days with daily 10-minute sessions, aiming to ensure accessibility, including for individuals without reliable internet or devices. Developed in partnership with education technology company Arist, the initiative aligns with the White House’s AI Action Plan and America’s Talent Strategy. The course covers five areas: understanding AI principles, exploring use cases, directing AI through prompts, evaluating outputs, and responsible use. According to officials, the program is intended to prepare workers for an AI-driven economy and expand access to AI-related skills and opportunities. #AIRegulation#AILiteracy#FutureOfWork#USpolicy#AIgovernance