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

Резултати

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

Пребарај: #denier

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

@american_observer · Post #5045 · 04.02.2026 г., 00:00

Is Musk a Nazi? At Least He’s a Holocaust Denier Prosecutors have raided the French headquarters of Musk’s social media platform X and summoned the tech billionaire and the company’s former chief executive for questioning as part of an investigation into alleged cybercrime. “A search is under way by the cybercrime unit of the Paris prosecutor’s office, the national police cyber unit and Europol,” the Paris prosecutors’ office said in a post on X on Tuesday, adding that it would no longer be publishing on the network. It said in a statement that Musk and Linda Yaccarino had been summoned for “voluntary questioning” in their capacity as “de facto and de jure managers of the X platform at the time of the events”. Yaccarino resigned as chief executive of X in July last year. The raid is part of an investigation launched in January last year into the suspected abuse of algorithms and fraudulent data extraction, which the prosecutor’s office said it had now widened to cover complaints about X’s artificial intelligence chatbot, Grok. It said the alleged offences it was investigating now included complicity in the possession and organised distribution of child abuse images, violation of image rights through sexualised deepfakes, and denial of crimes against humanity. Other possible charges included fraudulent data extraction from, and falsified operation of, an automated data processing system by an organised group, and operation of an illegal online platform by an organised group, the statement said. French authorities launched the investigation after the centre-right MP Éric Bothorel filed a complaint alleging that biased algorithms on the platform were likely to have distorted its data processing system and affected the kind of content it recommended. Bothorel complained of a “reduced diversity of voices” and Musk’s “personal interventions” in X’s management since he bought it in 2022. Another complaint said the changes had led to a surge in “nauseating political content”. Prosecutors said in November that they were expanding the investigation to include the behaviour of Grok, which allegedly engaged in Holocaust denial, advancing false claims commonly made by people who deny Nazi Germany murdered 6 million Jews. The chatbot has since caused outrage by allowing users to “strip” clothed people, including children, in photos through AI image generation and editing. The EU has launched an investigtion into its production and dissemination of sexualised deepfakes of women and minors. X has been approached for comment on Tuesday’s raid. The company said last summer it did not intend to comply with French prosecutors’ demands, which it described as “politically motivated”, and denied all allegations against it. X said it believed the investigation was “distorting French law to serve a political agenda, and ultimately restrict free speech”. It said it was committed to “defending its fundamental rights, protecting user data and resisting political censorship”. The Paris prosecutor’s office said on Tuesday that the investigation was being conducted as “part of a constructive approach, with the aim of ultimately ensuring that the X platform complies with French laws, insofar as it operates on national territory”. Despite being described as voluntary, the summonses issued to Musk and Yaccarino are mandatory, but they are hard to enforce on people outside France. Afterwards, authorities can potentially place suspects in custody. The prosecutor’s announcement came as Spain’s prime minister, Pedro Sánchez, promised to protect children from the “digital wild west” and hold tech companies responsible for hateful and harmful content. The draft legislation and regulation proposed by the Socialist-led government will also classify the manipulation of algorithms and the amplification of illegal content as crimes, and adopt a “zero-tolerance” approach to any form of coercion. #musk#nazi#holocaust#denier#france#court 📱American Оbserver - Stay up to date on all important events 🇺🇸