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

Резултати

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

Пребарај: #blc

当前筛选 #blc清除筛选
BLC Market - mini-app BulCoin

@bulcoin_blc · Post #312 · 18.03.2026 г., 10:00

We have completed the first series of posts, where we showed the interface of the future BLC Market application. What's next. The project is now moving into the next phase: • interface testing within the Pioneers group • feedback collection • preparation of the backend part of the application • development of the referral system and game mechanics Also in development is the first game mechanic of the application - the tap module. It will become part of the BLC economic system. The next updates will be dedicated to: • application testing • referral mechanics • early participant system The development of the project continues. #BLC#freelance FAQ | BUY

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #314 · 27.03.2026 г., 17:25

We continue to show what the BLC Market will look like. Currently, the basic logic of interaction within the app is under development: — user profile — task structure — navigation within the interface This is the first layer on which the entire system will be built. Next, we will show how exactly users will interact with each other. #freelance#community#BulCoin#BLC#TON FAQ | BUY

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #202 · 29.03.2025 г., 11:00

✔Three monetization markets – risk reduction and long-term stability. ✔Growth of BulCoin value – constant turnover and liquidity support. ✔Legal protection – arbitration courts ensure fair transactions. ✔Easy access – BulCoin is easily purchasable with TON. 🔗Buy BulCoin: Dedust.io 🎁All promotions and giveaways: Telegram 🚀BulCoin – a financial revolution for the free market! #BLC#Crypto#TetworkState#Libertarians BUY

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #319 · 29.03.2026 г., 10:00

How interaction will work in BLC Market The main idea is to eliminate unnecessary intermediaries. User: - creates a task - receives responses - chooses a contractor Everything happens within one interface. We make the mechanics as simple as possible to lower the entry barrier. #freelance#tasks#BulCoin#BLC#TON FAQ | BUY

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #228 · 29.12.2025 г., 11:35

Our recommendation How to earn on pool-liquidity if you only have BulCoin? 1. Go to App.Tonco.io in the pools section and enter BLC in the search. 2. Click on Create position 3. Enter the minimum price above the market, and the maximum no less than $0.11. This will be the minimum price at the start of privatization in Chuvashia for BulCoin 4. Enter the amount and create 5. Now investors will buy BLC from you, and you will get the maximum profit from trading! #pool#tonco#liquidity#BLC FAQ | BUY

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #192 · 24.03.2025 г., 09:22

The composition of the Council of large Bulcoin holders consisting of top 10 1. Olesya Zhukovets 460m 2. Mischshi Oreshnikov 362m 3. Er Chon 260m 4. Irӗklӗx 200m 5. Suldin Nikita 197m 6. Oleksandr Yasenchuk 100m 7. Alexander Samokaev 72m 8. Alexander Zolotarev 51m 9. Vlasov Dmitry 45m 10. Oleg Yelkin 45m If you own more than 45m Bulcoin, you can write in our bot and get a place in the council of large holders #SKD#blc#Guide#dao

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #3 · 05.11.2024 г., 06:02

🚀 We are proud to present the first Chuvashia-Volga Bulgaria national cryptocurrency - BulCoin (BLC) 🌟 It is designed to support Chuvash culture, heritage, and economic growth 🌿 Join us on this exciting journey to the digital future! 💪 #BulCoin#BLC#Chuvashia#VolgaBulgaria#CryptoCommunity#DigitalEconomy @bulcoin_blc