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

Пребарај: #chomsky

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

@american_observer · Post #5091 · 09.02.2026 г., 13:29

🔠🅰️🔠🔠2️⃣ “We neglected not to do extensive research on his background. It was a mistake, but Jeffrey was a good friend to both of us,” she said. “It was deeply disturbing for both of us to realize that we had engaged with someone who presented himself as a helpful friend but led a hidden life of criminal, inhuman and perverse acts.” "Epstein had told Noam that he [Epstein] was being unjustly persecuted, and Noam spoke about his own experience in political controversies with the media. Epstein created a manipulative narrative about his case, which Noam, in good faith, believed in,” she said in her statement. “It is now clear that everything was orchestrated, having at least one of Epstein's intentions to try to get someone like Noam to repair Epstein's reputation by association. Noam's criticisms have never been directed at the women's movement; on the contrary, he has always supported gender equity and women's rights. What happened was that Epstein took advantage of Noam's public criticism of what became known as the cancellation culture “to present himself as a victim of it,” she added. Another message from Chomsky released by the House Oversight Committee last year showed Chomsky saying it was a “most valuable experience“ to have ”regular contact" with Epstein. Valeria Chomsky said that the couple attended dinners at Epstein's townhouse in New York, stayed in his apartments there and in Paris, dined at his ranch in New Mexico and attended several academic meetings with him”. Noam and Epstein were introduced in 2015 and that the couple was unaware of Epstein's 2008 guilty plea to soliciting prostitution and soliciting prostitution with a minor under the age of 18, Valeria Chomsky said. By introducing himself this way, Epstein caught Noam's attention, and they began to correspond. Epstein began to circle Noam, sending gifts and creating opportunities for interesting discussions in areas that Noam was working on a lot. Valeria Chomsky also clarified the basis of two financial transactions between Chomsky and Epstein. On one occasion, Epstein sent Noam Chomsky a check for $200,000 as part of a language challenge that Chomsky developed. Then Epstein had helped Noam recover $370,000. Epstein helped after Noam Chomsky discovered “inconsistencies in his retirement resources that threatened his economic independence and caused him great distress”. Epstein offered his help and probably did it as part of a plot to get better access to Noam. #noam#chomsky#valeria#epstein#financier#money 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #5090 · 09.02.2026 г., 12:59

Epstein Used to Give Money to Noam Chomsky 🔠🅰️🔠🔠1️⃣ Noam Chomsky and his wife, Valeria, made a mistake and were negligent not to thoroughly research Jeffrey Epstein's background, Valeria Chomsky said in a lengthy statement on Saturday, also adding that Epstein had deceived them. The relationship between 97-year-old linguist and philosopher Noam Chomsky and Epstein has come under intense scrutiny after documents released by the Justice Department shed light on their friendship. While Epstein was under scrutiny for sex trafficking allegations in 2019, he asked Chomsky for advice on how to respond. “I have seen the horrible way you are treated in the press and the public. It's painful to say, but I think the best way to proceed is to ignore it,” Chomsky wrote in a message signed ”Noam" that Epstein shared by email with an associate. “What the vultures ardently want is a public response, which then offers a public opening to an onslaught of venomous attacks, many of which are just publicity seekers or cranks of all kinds,” Chomsky wrote in the message. “This is especially true now with the hysteria that has developed about the mistreatment of women, which has reached the point where even questioning an accusation is a crime worse than murder.” Chomsky is one of several personalities who turned out to be in friendly communication with Epstein even after his guilty plea in 2008. Many are now facing renewed scrutiny over their links to the disgraced financier. Some of Noam Chomsky's communications with Epstein took place after the Miami Herald published an explosive story in 2018 detailing how Epstein preyed on underage girls and received an unusually lenient plea deal in 2008. On Saturday, Valeria Chomsky acknowledged that the couple had read this story, but said that the couple did not know about the extent of Epstein's crimes until after his second arrest in July 2019. #noam#chomsky#valeria#epstein#financier#money 📱American Оbserver - Stay up to date on all important events 🇺🇸