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

Резултати

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

Пребарај: #tradingbot

当前筛选 #tradingbot清除筛选
Propheta Indicator Signals

@propheta_indicator · Post #23772 · 06.05.2026 г., 10:21

👆 Propheta living up to its name yet again 🔮 Reached 9th TP in the VIP CLUB channel! Easy $455 with a 5% entry and a $1000 deposit! VIPs getting filthy rich by the day ☺️🤑🤑ACCESS TO MANUAL TRADING for 70usdt/month 💸Turn time into cash with Propheta AI Signals: pinpoint entries and exits, AI-powered automation, and perfect Cornix compatibility — your automated win streak! GET THE ACCESS TO AI SIGNALS Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #tradingviewindicator#tradingbot#buybtc

Propheta Indicator Signals

@propheta_indicator · Post #22995 · 03.11.2025 г., 17:35

👀 Well, would you look at that! 👆 Reached 9th TP in just 1 day in the VIP PRO channel! You could've earned $639 with a 5% entry and a $1000 deposit! 🤑 All this profit could have been yours! 🔥ACCESS TO MANUAL TRADING for 70usdt/month 💸Turn time into cash with Propheta AI Signals: pinpoint entries and exits, AI-powered automation, and perfect Cornix compatibility — your automated win streak! GET THE ACCESS TO AI SIGNALS Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #AItrading#buybtc#tradingbot

Propheta Indicator Signals

@propheta_indicator · Post #23681 · 08.04.2026 г., 08:25

Reached 9th TP in the VIP CLUB channel! With a 5% entry and a $1000 deposit, you could've earned $456! ACCESS TO MANUAL TRADING for 70usdt/month 👉 OOooh yeah baby! And that's what we do every day! Every day milking those exchanges dry! Waiting for you: t.me/ProphetaAdmin_bot Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #tradingbot#cryptobot#passiveincome

Propheta Indicator Signals

@propheta_indicator · Post #23324 · 13.02.2026 г., 16:10

👆 Propheta living up to its name yet again 🔮 Reached 9th TP in just 36 minutes in the VIP PRO channel! $277 in profits with a 5% entry and a $1000 deposit! That's why we call it the "Money Printer" 💴💷💵ACCESS TO MANUAL TRADING for 70usdt/month 👉 Did you know that our referral partners receive extra discounts, even cumulative with the special offer prices? START >>> Referral Program Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #buycrypto#tradingbot#AItrader

Propheta Indicator Signals

@propheta_indicator · Post #23577 · 27.03.2026 г., 01:57

👆 OMG! Would you look at that 👀 Reached 9th TP in just 9 hours in the VIP PRO channel! Using a 5% entry you could've earned $401 with a $1000 deposit Feels good to be a Propheta VIP, man... 🏖ACCESS TO MANUAL TRADING for 70usdt/month 👉 Join us and earn big! Start here: t.me/ProphetaAdmin_bot Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #AItrading#CryptoSignal#tradingbot

Propheta Indicator Signals

@propheta_indicator · Post #23309 · 05.02.2026 г., 21:46

👆 Propheta living up to its name yet again 🔮 Reached 9th TP in just 9 hours in the VIP CLUB channel! That's why we call it the "Money Printer" 💴💷💵ACCESS TO MANUAL TRADING for 70usdt/month 👉 Looking at those reports and can't believe what you're seing? Go to our reports channel and audit us! @propheta_reports Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #tradingbot#indicator#autotrading

Propheta Indicator Signals

@propheta_indicator · Post #22888 · 10.10.2025 г., 15:31

👍 This is why we're here! Reached 9th TP in the VIP HTL channel! Feels good to be a Propheta VIP, man... 🏖ACCESS TO MANUAL TRADING for 70usdt/month 💸Turn time into cash with Propheta AI Signals: pinpoint entries and exits, AI-powered automation, and perfect Cornix compatibility — your automated win streak! GET THE ACCESS TO AI SIGNALS Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #tradingbot#signalchannel#AItrader

Propheta Indicator Signals

@propheta_indicator · Post #23189 · 12.12.2025 г., 06:19

👆 OMG! Would you look at that 👀 Reached 9th TP in just 2 hours in the VIP CLUB channel! Easy $338 with a 5% entry and a $1000 deposit! ACCESS TO MANUAL TRADING for 70usdt/month 👉 Multiplying deposits every day! Not convinced? Contact us for a free trial - @propheta_help Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #tradingbot#cryptomarket#cryptocurrency

Propheta Indicator Signals

@propheta_indicator · Post #23727 · 17.04.2026 г., 00:03

Oops, we did it again 🤣 Reached 9th TP in just 17 hours in the VIP PRO channel! Easy $609 with a 5% entry and a $1000 deposit! VIPs getting filthy rich by the day ☺️🤑🤑ACCESS TO MANUAL TRADING for 70usdt/month 👉 We know how to earn 3-4-5 digit amounts without any deposit, with zero risk! Click the link, then START >>> Referral Program Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #cryptoexchange#ethereum#tradingbot

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