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

Резултати

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

Пребарај: #bulcoin

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

@bulcoin_blc · Post #258 · 23.02.2026 г., 17:00

If you're just considering BulCoin — here's what you can do right now: 1️⃣ Create a TON-wallet 2️⃣ Add BLC manually 3️⃣ Check trading pairs 4️⃣Find out what you can buy with BulCoin 5️⃣ Keep up with DAO decisions on our channel This is the system entry. BulCoin is being built as an infrastructure. And infrastructure requires participation. Those who enter earlier - understand the mechanics better. #BulCoin FAQ | BUY

Hashtags

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #250 · 17.02.2026 г., 09:30

🟡 Why is BulCoin (BLC) needed at all BulCoin is not just a token. It's a part of infrastructure. Infrastructure where transactions are made without intermediaries. Without blockages. Without "permissions". We are creating an environment where: • value is transferred directly • calculations are made in digital form • participants interact without third parties Mini-app is the first step in using BLC. More to come. A free market is impossible without its own infrastructure. BulCoin is an element of such a system. #BulCoin FAQ | BUY

Hashtags

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #261 · 25.02.2026 г., 11:00

🔥 We are opening the first round of BulCoin participants! 20 random participants will be selected. Each will receive 200 000 BLC. Additionally, a team of 50 early testers of the mini-app will be formed. Participation conditions: — subscription to the channel — comment under this post specifying your TON-address Results will be in 7 days. Results announcement date: 2026-03-04 at 20:00. This is the first stage of forming an active core of BulCoin. #giveaway#BulCoin FAQ | BUY

Асқарбиновая Орда

@askar4308 · Post #15265 · 25.02.2026 г., 17:07

🔥 We are opening the first round of BulCoin participants! 20 random participants will be selected. Each will receive 200 000 BLC. Additionally, a team of 50 early testers of the mini-app will be formed. Participation conditions: — subscription to the channel — comment under this post specifying your TON-address Results will be in 7 days. Results announcement date: 2026-03-04 at 20:00. This is the first stage of forming an active core of BulCoin. #giveaway#BulCoin FAQ | BUY

🔥 Мы открываем первый круг участников BulCoin! Будет выбрано 20 случайных участников. Каждый получит 200 000 BLC. Дополнительно формируется команда из 50 ранних тестеров mini-app. Условия участия: — подписка на канал — комментарий под этим постом указав свой TON-адрес Итоги — через 7 дней. Дата подведения итогов: 2026-03-04 в 20:00. Это первый этап формирования активного ядра BulCoin. #giveaway#BulCoin FAQ | Купить

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #242 · 14.02.2026 г., 19:30

Why do you need BulCoin (BLC)? BulCoin is not just a token. It's an early stage of an ecosystem that is being built around: • a mini-game app • digital economy • early participant community The project is currently in the formation phase. It's at this stage that: — the core of the community is being formed — the first holders appear — history is being laid BulCoin (BLC) is a TON network token. In the coming months, a mini-app will be launched, where BLC will become the gaming currency. But the main thing is that early participants get more opportunities. We don't make loud promises. We are building the system step by step. If you have already created a wallet - you are prepared. It's going to be more interesting from here. #BulCoin#TON#DAO 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

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