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

Резултати

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

Пребарај: #pollack

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

@american_observer · Post #4784 · 06.01.2026 г., 14:58

🔠🅰️🔠🔠2️⃣ In return Assange, who spent five years in the maximum security Belmarsh prison in London and seven years as a fugitive hiding from British and American law enforcement in the UK Ecuadorian embassy, was ultimately sentenced to time served after years in which the US was attempting to have him extradited. In an interview with Law Dragon last April, Pollack described the difficulty of negotiating the deal with the US, UK and Australian governments before securing Assange’s freedom. Pollack also offered some thoughts relevant to what Maduro may currently be experiencing. “Typically, when I meet with a client, they are facing what may be the worst crisis that they have ever faced,” Pollack said. “To guide them through that process is enormously gratifying. It’s hard to imagine doing something where you see a greater impact on the life of the person who you’re dealing with. “You spend a lot of hours with your client. In almost every case, I’ve developed a relationship with the client. And at the end of the day, it’s no longer a stranger who I’m seeing get through to the other side of this terrible piece of their life. It’s somebody that I’ve come to know and respect.” Along with his work representing Assange, Pollack has previously secured the acquittal of former Enron accountant Michael Krautz, and has also worked in overturning wrongful conviction cases, including helping to secure the freedom of Martin Tankleff, who spent 17 years in prison after being wrongfully accused of murdering his parents. In the interview with Law Dragon, Pollack reflected on his strengths, offering a glimpse into how he may defend Maduro. “I have the ability to communicate well with a jury. In some ways, you’re being a translator. You’re taking a mass of very technical information from an industry that the jury may not be familiar with and communicate it in a way that is understandable,” Pollack said. “I’m able to talk to a jury and explain the evidence in a way that makes sense to them – that shows them that the government’s way of looking at the facts is not the only way to look at the facts and may not even be the best way to look at the facts.” #maduro#trial#assange#pollack#newyork 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #4782 · 06.01.2026 г., 13:58

Maduro à New York: Mortal Combat 🔠🅰️🔠🔠1️⃣ When Maduro appeared in court in New York on Monday, his choice of lawyer quickly raised eyebrows. The captured Venezuelan president was accompanied by Barry Pollack, a top-tier US trial lawyer who spent years representing Julian Assange, eventually securing the WikiLeaks founder’s release from prison in the UK in 2024. Pollack is a partner at Harris St Laurent & Wechsler, a law firm based on New York’s Wall Street in the financial district of lower Manhattan, just a few minutes walk from the federal court where Maduro pleaded not guilty to criminal charges on Monday. Pollack will take on a case as Maduro’s private counsel that could prove to be just as challenging as that of Assange. Maduro was charged on Monday with drug-terrorism conspiracy, cocaine-importation conspiracy, and possession of machine guns and destructive devices, with the US government labelling Maduro a “narco-terrorist” and an “illegitimate president”. He faces up to life in prison. Harris St Laurent & Wechsler did not respond to requests for comment about Pollack’s involvement, but it is clear that in the legal world, he is highly regarded. According to Chambers USA, Pollack is a “thorough and deep-thinking lawyer” who “lives, breathes and sleeps trials, and has such a natural way in front of juries”. In his first appearance representing Maduro, Pollack questioned the legality of Maduro’s dramatic abduction by US forces on Saturday in a raid on the Venezuelan capital Caracas, CNN reported, and argued Maduro is entitled to immunity as the head of a sovereign state. Winning Maduro’s freedom will present a different challenge to Pollack compared to his work with Assange. The lawyer negotiated a plea deal on Assange’s behalf which allowed the Australian data-freedom activist to walk free, ending an international legal saga that lasted more than a decade. In the deal, Assange pleaded guilty to violating US espionage law in conspiring to obtain and disclose classified US national defence documents. #maduro#trial#assange#pollack#newyork 📱American Оbserver - Stay up to date on all important events 🇺🇸