Можно ли в 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
🤣 Trending now: #Crypto - Jim Cramer calls for a sharp rally, but history says otherwise. #Markets#Investing
🤣 《瘋狂金錢》主持人 Jim Cramer 今日預測加密市場將出現強勁反彈,不過其過往預測多次與實際走勢相反,引發市場熱議。
投資者普遍保持謹慎,視其言論為市場情緒的反向指標。 #Insight
@EthereumGlobalNews Follow for more global Web3 & DeFi updates!
🗳️ Cast your vote — tell us where #BTC goes next!
Live Forex News Today — Global FX Market Update (February 24, 2026) https://www.fxpremiere.com/live-forex-news-today-global-fx-market-update-february-24-2026/#forextrading#forextrading#money#Investing FxPremiere Group Make Money Online - FxPremiere Group Nasdaq
Live Forex News Today (Feb 27, 2026): PBOC Moves Cool Yuan, AUD Outperforms, Yen Under Pressure https://www.fxpremiere.com/live-forex-news-today-feb-27-2026-pboc-moves-cool-yuan-aud-outperforms-yen-under-pressure/#forextrading#forex#money#investing Make Money Online - FxPremiere Group FxPremiere Group FxPremiere Telegram Alerts
Live Forex News Today — Global FX Market Update (February 20, 2026) | FXPremiereLive Forex News Today — Global FX Market Update (February 20, 2026) | FXPremiere https://www.fxpremiere.com/live-forex-news-today-global-fx-market-update-february-20-2026/#forextrading#forex#money#investing Make Money Online - FxPremiere Group FxPremiere Group FxPremiere Telegram Alerts
Live Forex USA News Today — USD Market Update (4 February 2026) https://www.fxpremiere.com/live-forex-usa-news-today-usd-market-update-4-february-2026/#forextrading#forex#money#investing Make Money Online -
#ALV#research#investing
Autoliv Inc. – шведско-американская компания, основанная в середине XX века, специализируется на системах автомобильной безопасности.
Её продукция включает:
📍Подушки безопасности (фронтальные, боковые, занавесочные)
📍Ремни безопасности (инерционные катушки, преднатяжители, крепления)
📍Рулевые колеса с интегрированными системами безопасности
📍Некоторые электронные компоненты безопасности для автомобилей
Autoliv присутствует по всему миру, располагая производственными и инжиниринговыми центрами в Северной и Южной Америке, Европе и Азии.
👉Ключевые клиенты – практически все крупные автопроизводители, включая Toyota, Volkswagen, General Motors, Ford, Stellantis (PSA + FCA), BMW, Daimler (Mercedes), Tesla, китайские производители (Geely, Great Wall) и многие другие.
Подробное описание компании, фундаментальное состояние, технический анализ и вердикт:
📌 ЧИТАТЬ СТАТЬЮ (подписка)
📣📣 6 DAYS LEFT UNTILNEW PUMP📣📣
Date : Friday, 23 February
Time : 17:00 PM (GMT)
Exchange : Kucoin.com
Target : +700%
Pairing : USDT
🚀DISCOUNTED PRICES FOR LIMITED TIME ONLY
🚀
🔥Exclusive for our esteemed VIP Members, a private event awaits you this week. the clock is ticking‼️ Don't miss your chance to secure a spot in this elite circle. Join the ranks of success and seize your VIP status!
SLOTS REMAINING: 7The Clock is ticking! If you've missed:
$SQUAD 328 🛍October 1💵💸
$WOMBAT 753🛍October 8💵💸
$APIEK 594🛍October 15💵💸
$EGAME 740🛍October 29💵💸
$MONI 325🛍November 5💵💸
$HALO 138🛍November 19 💵💸
$PEEL 324🛍November 26 💵💸
$SUIA 349🛍December 3 💵💸
$QUICK 1270🛍December 23 💵💸
$IZI 295🛍December 28 💵💸
$MJT 747🛍January 19💵💸
$VERSE 174🛍January 21💵💸
$WHALE 145🛍February 04💵💸
$ODDZ 195🛍February 11💵💸
In 4 Months our VIP MEMBERS MADE 6271🛍 PROFIT.💵💸
We Are the BIGGEST and most profitable pump Channel, and you will have the chance to join us and make your future Bright. 💸
Secure your entry by accessing the membership form HERE
https://forms.gle/gJWehoAa4vi2LQkC6
☄️Your moment of triumph is now. Unleash the potential within you and ride the wave of prosperity. Act swiftly, and let's reach new heights together!
Got any Questions? @RobertMillercrypto
#Crypto#CryptoSignals#cryptopumps#signals#cryptopumps#investing
📣📣 2 DAYS LEFT UNTILNEW PUMP📣📣
Date : Sunday, 18 February
Time : 17:00 PM (GMT)
Exchange : Kucoin.com
Target : +700%
Pairing : USDT
🚀DISCOUNTED PRICES FOR LIMITED TIME ONLY
🚀
🔥Exclusive for our esteemed VIP Members, a private event awaits you this week. the clock is ticking‼️ Don't miss your chance to secure a spot in this elite circle. Join the ranks of success and seize your VIP status!
SLOTS REMAINING: 1The Clock is ticking! If you've missed:
$SQUAD 328 🛍October 1💵💸
$WOMBAT 753🛍October 8💵💸
$APIEK 594🛍October 15💵💸
$EGAME 740🛍October 29💵💸
$MONI 325🛍November 5💵💸
$HALO 138🛍November 19 💵💸
$PEEL 324🛍November 26 💵💸
$SUIA 349🛍December 3 💵💸
$QUICK 1270🛍December 23 💵💸
$IZI 295🛍December 28 💵💸
$MJT 747🛍January 19💵💸
$VERSE 174🛍January 21💵💸
$WHALE 145🛍February 04💵💸
$ODDZ 195🛍February 11💵💸
In 4 Months our VIP MEMBERS MADE 6271🛍 PROFIT.💵💸
We Are the BIGGEST and most profitable pump Channel, and you will have the chance to join us and make your future Bright. 💸
Secure your entry by accessing the membership form HERE
https://forms.gle/gJWehoAa4vi2LQkC6
☄️Your moment of triumph is now. Unleash the potential within you and ride the wave of prosperity. Act swiftly, and let's reach new heights together!
Got any Questions? @RobertMillercrypto
#Crypto#CryptoSignals#cryptopumps#signals#cryptopumps#investing
📣📣 3 DAYS LEFT UNTILNEW PUMP📣📣
Date : Sunday, 18 February
Time : 17:00 PM (GMT)
Exchange : Kucoin.com
Target : +700%
Pairing : USDT
🚀DISCOUNTED PRICES FOR LIMITED TIME ONLY
🚀
🔥Exclusive for our esteemed VIP Members, a private event awaits you this week. the clock is ticking‼️ Don't miss your chance to secure a spot in this elite circle. Join the ranks of success and seize your VIP status!
SLOTS REMAINING: 2 The Clock is ticking! If you've missed:
$SQUAD 328 🛍October 1💵💸
$WOMBAT 753🛍October 8💵💸
$APIEK 594🛍October 15💵💸
$EGAME 740🛍October 29💵💸
$MONI 325🛍November 5💵💸
$HALO 138🛍November 19 💵💸
$PEEL 324🛍November 26 💵💸
$SUIA 349🛍December 3 💵💸
$QUICK 1270🛍December 23 💵💸
$IZI 295🛍December 28 💵💸
$MJT 747🛍January 19💵💸
$VERSE 174🛍January 21💵💸
$WHALE 145🛍February 04💵💸
$ODDZ 195🛍February 11💵💸
In 4 Months our VIP MEMBERS MADE 6271🛍 PROFIT.💵💸
We Are the BIGGEST and most profitable pump Channel, and you will have the chance to join us and make your future Bright. 💸
Secure your entry by accessing the membership form HERE
https://forms.gle/gJWehoAa4vi2LQkC6
☄️Your moment of triumph is now. Unleash the potential within you and ride the wave of prosperity. Act swiftly, and let's reach new heights together!
Got any Questions? @RobertMillercrypto
#Crypto#CryptoSignals#cryptopumps#signals#cryptopumps#investing
Forex News Today – March 10, 2026 https://www.fxpremiere.com/forex-news-today-march-10-2026/#forex#finance#money#investing Make Money Online - FxPremiere Group FxPremiere Group FxPremiere Telegram Alerts Nasdaq
Live Forex News Today — Global FX Market Update (31 January 2026) https://www.fxpremiere.com/live-forex-news-today-global-fx-market-update-31-january-2026/#forex#finance#money#investing Make Money Online