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

Резултати

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

Пребарај: #deals

当前筛选 #deals清除筛选
Desi Memes Funny Jokes

@DESI_MEMES_Funny_Jokes · Post #7089 · 01.05.2025 г., 17:05

Great Summer Sales from tomorrow!! Join now and get notified to exciting and jaw-dropping #deals and #loots🔥 https://t.me/+tNuUiQLlNNIzZGFl https://t.me/+tNuUiQLlNNIzZGFl

Hashtags

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #299 · 13.03.2026 г., 10:00

How the deal will be conducted in BLC Market We continue to showcase the interface of the upcoming BLC Market app. Today — how the deal between the client and the contractor will take place. When the client selects a contractor, a deal is created within the platform. The process looks like this: • the client creates a deal • funds are blocked within the platform • the contractor performs the work • after confirmation, the result is transferred to the client • funds are transferred to the contractor Such a system allows to protect both parties of the deal and reduce the risk of fraud. All calculations within the platform will be conducted using BLC without commission, or with the token chosen by the user, for a commission - which will go to the BLC liquidity pool. In the following posts we will show: • how the arbitration system works • what happens if a dispute arises • how users can protect their interests Early access to interface testing is granted to Pioneers participants. #tasks#freelance#deals

BLC Market - mini-app BulCoin

@bulcoin_blc · Post #294 · 10.03.2026 г., 10:00

How the task search will work in BLC Market We continue to demonstrate the interface of the future BLC Market application. Today - how users will be able to find tasks and performers. The application will have a convenient search, where you can: • view available tasks • filter by categories • search by keywords • choose tasks by budget Each task will have a card with a description, price, and completion time. Performers will be able to quickly find suitable tasks and send their proposals to customers. This creates a full-fledged service market where customers and performers can interact directly. In the following posts, we will show: • how a deal is made within the platform • how deal protection works • how crypto-arbitrage will be arranged Early access to interface testing is given to Pioneers participants. #tasks#freelance#deals FAQ | BUY

纯情男高

@hanzichen · Post #706 · 11.05.2025 г., 17:13

AppSumo A platform that offers lifetime deals on software and digital tools for entrepreneurs, developers, and small businesses. AppSumo helps you discover new and useful apps at heavily discounted prices — often one-time payments instead of recurring subscriptions. 🔗 Links: - Website - Softwares - YouTube - Blog ❗️Friendly reminder: If you find it useful, You may star the repo/app, donate to the developer, or perhaps you may also contribute to the development of this project. 🏷 Tags: #Website#Deals#LifetimeDeals

Desi Memes Funny Jokes

@DESI_MEMES_Funny_Jokes · Post #5423 · 11.10.2024 г., 12:28

🌟EAR BUDS @ ₹39🌟 🔥LOOT DEAL OF THE DAY🔥 🛍Grab fast before it gets Out of stock. Get similar deals in future by joiningLoot Indian Deals🛍 🔰Note- Check all deals instantly 🔰 #Loots#Indian#Deals#offers

App Store Deals

@appstoredeals · Post #739 · 23.05.2024 г., 11:13

FREE GAME❗💥 🔹 Anti Pong is now free for a limited time❗ (was $0.99) ✨ Avoid The Ball! ❌ ENDEDhttps://apple.co/3wCZ667 💬great twist on a classic game. enjoy local multiplayer and smooth dark mode. highly recommended! ⚡️Boost🔸@AppStoreDeals#apple#deals#free#apps

Daily Channels

@dailychannels · Post #6760 · 20.03.2026 г., 13:00

Channel: Amazon.com USA Deals Members: ~3.15K 💢 Username: @dealsunlimitedusa Description: Great selection of the best Amazon.com deals every day! 🏷 Tags: #shop #amazon#amazon.com #shopping#sales#deals https://lve.to/4glrsiawix

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40064 · 11.11.2025 г., 06:01

Singles’ Day ✨🛍️ November 11 (11.11) — the date’s four "1"s symbolize single life. What began in the 1990s as a playful “anti-Valentine’s” celebration in China has grown into one of the largest shopping days in the world! @googlefactss [Read more] #SinglesDay #1111 #SelfCare#ShopSmart#Deals#November11#FunFacts#History

Trump and Mirziyoyev exchanged compliments in New York, discussed multi-billion dollar deals, and extended invitations for further cooperation (meeting video analysis). https://yep.uz/en/2025/09/trump-mirziyoyev-compliments-deals-samarkand/ #trump#mirziyoyev#uzbekistan#samarkand#deals#nyc#un#news#cooperation