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

Резултати

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

Пребарај: #melania

当前筛选 #melania清除筛选

На #MELANIA отключили маркетмейкера. Объемы не крутят. Вот он реальный спрос и предложение. Интересно, это так хотят вытрясти из нас жетоны или такой тупой скам?

Hashtags

Ладно, уговорили. Взял Миланку на 1 SOL, хотя не люблю заходить на росте. Это просто рулетка, выиграешь, не выиграешь. Тейк поставил 30$. Кто захочет полудить, рекомендую Alpha DEX. Там и стоп и тейк можно поставить. Очень удобный терминал. #MELANIA

Hashtags

Crypto Samurai | News & Memes

@cryptosamuraicat · Post #548 · 20.01.2025 г., 08:27

☄️Melania Trump launches her memcoin #MELANIA Official tweet: link Donald Trump reposted her post on Twitter. 🔖There was no information about a possible hack. 🔖 If you are not familiar with DEX, then wait for the listing on the Bybit exchange. 🐱🐱🐱🐱🐱🐱🐱🐱 👉🏻SUBSCRIBE!

Hashtags

Trump's Ear

@trumpsear_tg · Post #1950 · 24.12.2025 г., 20:50

Trump sent out Christmas greetings with his gloomy face The White House is sending out Christmas greetings with a photo of US President Donald Trump and his wife Melania. However, their appearance is not festive at all — both are staring at the camera with serious expressions on their faces. No smile, no Christmas mood! The photo was taken on December 7 in the White House Cross Hall. Both are dressed in black. Melania is wearing a long black sleeveless dress. She wore pearl earrings and a diamond bracelet with it. President Trump poses in a black tuxedo with a black bow tie and patent leather shoes. Stylish and elegant — no questions asked! But it didn't work out to be a warm Christmas photo. The congratulations with which the White House addresses citizens also sound cold and formal: In addition, there is an emoji of the American flag. Many people used the phrase "Make Christmas Great Again" to comment on the photo and laugh at the sight of the presidential couple. "They look like they're going to a funeral," wrote one user. Trump and Melania can pose for Christmas greetings much more joyfully. They have already proved it. For example, in the official Christmas portrait from the White House in 2017, both were smiling broadly and generally looked more relaxed and happy. #Trump#Melania 👂More on Trump's Ear

Trump's Ear

@trumpsear_tg · Post #2096 · 03.02.2026 г., 18:00

The film about Melania Trump set a record at the box office The documentary called "Melania" earned $8 million in its first weekend. This is the best start for documentary films in the last ten years, they claim in the White House. #Melania#Media 👂More on Trump's Ear ⚠️

Trump's Ear

@trumpsear_tg · Post #2036 · 21.01.2026 г., 17:29

Melania Trump's long-anticipated documentary debut is facing early headwinds, with advance ticket sales reportedly falling well short of expectations just weeks before its scheduled premiere. The film, titled "MELANIA" and directed by Brett Ratner, is said to have carried a production budget of roughly $40 million and promises an unusually intimate look at Trump's time as first lady, as well as her marriage to President Donald Trump. #Melania#Media 👂More on Trump's Ear ⚠️

Trump's Ear

@trumpsear_tg · Post #1679 · 23.10.2025 г., 13:59

📚A whistleblower journalist has sued Melania Trump for defamation and disrupting the publication of his book.💼 Now he's demanding millions of dollars from her. 💰 American writer and investigative journalist Michael Wolff is making serious allegations against the First Lady of the United States. 🇺🇸 He claims that she deliberately organized a campaign to silence him. 🤐 The reason was Wolff's upcoming book The Art of Her Deal: The Untold Story of Melania Trump. According to the journalist, the First Lady “intentionally” interfered with his publishing contract and publicly slandered him. Michael Wolff is a world-renowned author of incisive political revelations, primarily thanks to his bestseller Fire and Fury: Inside the Trump White House published in 2018. 🔥 On 480 pages, he provided detailed descriptions of the backstage life of the Trump administration, which provoked a strong reaction from the president himself. Melania’s team, according to the journalist, spread rumors that he was inventing interviews, intimidating sources, and writing “lies for profit”, according to the TMZ portal. 📰 As a result, Wolff argues, international partners in promoting the book refused to cooperate, and the book deal fell through. In addition, in his complaint, Wolff states that Melania personally instructed the PR agency to threaten lawsuitsagainst those publications that intended to write about his book. The journalist also provided a letter from Melania Trump’s lawyers demanding that he withdraw allegedly defamatory allegations about the First Lady’s possible ties to convicted sex offender Jeffrey Epstein. ⚖️ Melania Trump’s lawyers strongly deny all charges. Wolff has now filed a lawsuit against the First Lady for millions of dollars in damages and is demanding that the court officially confirm that the contents of his new book are not defamation. 📖 #Melania#Media 👂More on Trump's Ear ⚠️

ПретходнаСтраница 1 од 4Следна