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

Пребарај: #clintons

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

@american_observer · Post #5037 · 03.02.2026 г., 14:00

Have the Clintons Been Cosing Up to Epstein? Bill and Hillary Clinton agreed on Monday to testify in a House investigation into the convicted sex offender Jeffrey Epstein, days before the chamber was expected to vote to hold them in contempt of Congress. The concession follows a tense back-and-forth between the Clintons and the Republican James Comer, chair of the House oversight committee, who on Monday said that he would insist both Clintons sit for a sworn deposition before the committee in order to fulfill the panel’s subpoenas. “They negotiated in good faith. You did not,” Angel Ureña, a spokesman for the Clintons, replied to Comer, in a post on social media. “They told you under oath what they know, but you don’t care. But the former president and former secretary of state will be there. They look forward to setting a precedent that applies to everyone.” The House was headed towards potential votes this week on criminal contempt of Congress charges against the Clintons. If passed, the charges threatened the Clintons with substantial fines and even incarceration if they were convicted. For months, the Clintons had refused to appear before the Republican-led panel, arguing that the subpoenas were legally “invalid” and “unenforceable” and accusing Comer of targeting them as part of Trump’s retribution campaign against his political enemies. A committee letter to the Clintons’ attorneys indicates the pair had offered for Bill Clinton to conduct a transcribed interview on “matters related to the investigations and prosecutions of Jeffrey Epstein” and for Hillary Clinton to submit a sworn declaration. The demand for testimony “runs afoul of the clearly defined limitations on Congress’s investigative power propounded by the supreme court of the United States”, they wrote, adding: “It is clear the subpoenas themselves – and any subsequent attempt to enforce them – are nothing more than a ploy to attempt to embarrass political rivals, as President Trump has directed.” Nine of the committee’s 21 Democrats joined Republicans in support of the charges against Bill Clinton as they argued for full transparency in the Epstein investigation. Three Democrats also supported the charges against Hillary Clinton. Bill Clinton’s relationship with Epstein has re-emerged as a focal point for Republicans amid the push for a reckoning over Epstein, who killed himself in 2019 in a New York jail cell as he faced sex-trafficking charges. Clinton, like a bevy of other high-powered men, including Trump, had a well-documented social relationship with Epstein in the late 1990s and early 2000s. He has not been accused of wrongdoing in his interactions with the late financier. On Friday, more than 3m files related to Epstein were released by the Department of Justice, including more than 2,000 videos and 180,000 images. The files included a series of emails between Musk and Epstein, indicating a friendlier relationship than was previously known. Following the drop of the latest batch of files, Democrats have promised to fight what they are calling a “full-blown cover-up” of the Epstein files after the Trump administration on Sunday effectively declared its investigation into the disgraced late financier and sex trafficker was closed. After Bill and Hillary Clinton were subpoenaed in August by the House oversight committee, their attorney had tried to argue against the validity of the subpoena. However, as Comer threatened to begin contempt of Congress proceedings, they started negotiating towards a compromise. #clintons#hilary#bill#epstein#trump#republicans#sex 📱American Оbserver - Stay up to date on all important events 🇺🇸