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

Резултати

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

Пребарај: #userprotection

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

@ai_and_law · Post #43 · 30.06.2023 г., 07:04

Are your favorite Apps invading your privacy? Let's find out! Artificial Intelligence has become a hot topic, raising questions about its impact on user privacy. Are AI apps really intruding on our personal data? A recent investigation by Home Security Heroes (HSH) reveals some eye-opening findings. By examining various AI applications, HSH has uncovered the extent of data intrusion facilitated by AI technology. To determine the invasiveness of AI apps, HSH used the privacy labels available on the App Store. These labels reveal the amount of personal information an app tracks for marketing purposes. They evaluated a total of 159 apps. Key Insights: 1️⃣ 75% of AI apps share users' data with third parties. 2️⃣ 64% of investigated AI-powered apps track users' personal data for their own marketing benefits. The Most Invasive AI Apps: 🔹 Tracking 43% of personal data: Brainly Photoleap: AI Art Photo Editor 🔹 Tracking 36% of personal data: Google Assistant Socratic by Google DaVinci – AI Generated Art Facetune AI Photo/Video Editor How comfortable are you with AI apps tracking and sharing your personal data? Are the benefits worth the potential risks to your privacy? #AI#Privacy#DataSecurity#UserProtection#AIApps

Crypto M - Crypto News

@CryptoM · Post #64897 · 10.04.2026 г., 07:57

🚀 Aethir Blocks Vulnerability Attack, Plans Compensation for Users Aethir has successfully thwarted a vulnerability attack on its bridge contract, estimating user losses to be around $90,000. According to NS3.AI, the company assured that ATH on Ethereum remains secure. Aethir is set to announce a compensation plan for affected users next week. #Aethir#VulnerabilityAttack#CompensationPlan#Ethereum#CryptoSecurity#NS3AI#UserProtection

Crypto M - Crypto News

@CryptoM · Post #65128 · 11.04.2026 г., 07:24

🚀 South Korea Considers Seizing Principal in Virtual Asset Insider Trading Cases South Korea's financial regulators are contemplating the inclusion of a clause to seize the principal in virtual asset insider trading cases in the upcoming second phase of legislation expected later this year. According to PANews, under the current Virtual Asset User Protection Act, the government can only confiscate investment principal in cases of fraudulent transactions or market manipulation. There is no legal basis for seizing the principal in insider trading cases. The Financial Supervisory Service has recently submitted this issue to the Financial Services Commission, which is currently reviewing whether to incorporate it into the second phase of the law. In the stock market, all improper trading crimes can result in the confiscation of the investment principal. #SouthKorea#VirtualAssets#InsiderTrading#FinancialRegulation#Legislation#InvestmentPrincipal#FinancialSupervisoryService#FinancialServicesCommission#MarketManipulation#UserProtection#StockMarket