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

Резултати

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

Пребарај: #binancecoin

当前筛选 #binancecoin清除筛选
We want you

@we_want_youu · Post #4230 · 15.08.2024 г., 11:09

After falling from the support level of $500.0, #BinanceCoin reached the support level of $400.0 and recovered and is now trading above both levels. As you can see in the chart, a dynamic resistance still prevents #BNBUSDT growth, so in the first step, crossing and breaking this resistance can be a sign of the continuation of the upward trend in the daily time frame. So far, BNBUSDT has hit the dynamic resistance 2 times and failed to break it, these collisions may reach up to 5 times and then the price will start to grow. The current price movement scenario is between the $400.0 support and the dynamic resistance.

🐓✨Tencent PP Ranch✨

@tencentppranch012 · Post #9 · 10.08.2024 г., 05:18

Easily earn a small income, Tencent PP Ranch Golden Egg Picking Guide! Dear QQ Ranch friends, today, we are going to share how to easily make money in Tencent PP Ranch by picking up golden eggs! Just a few steps to make your virtual farm more abundant, earn money now! ———————— 📚 1. Understand how to get golden eggs First of all, golden eggs are a rare resource in QQ Ranch, which are picked up by participating in daily activities, completing tasks or within a specific time period. Remember to go online regularly to ensure that you don’t miss them! 📚 2. Improve the efficiency of picking eggs ⦁ Reasonable time arrangement: Choose the peak period of popularity to enter the game, and the chance of getting golden eggs is greater. ⦁ Add friends: help other players and share the experience and skills of picking eggs. 📚 3. Trade with golden eggs The golden eggs you pick up can be sold through the in-game trading system to get game coins or other rewards. Pay attention to market trends, choose the best time to make a move, and maximize your profits! 📚 4. Participate in activities to get more rewards Regularly participate in various activities of Tencent PP Ranch, and there will often be extra golden egg rewards to increase your small treasury. Pay attention to game announcements and participate in time! 📚 5. Continue to invest and enjoy the fun Persist in going online every day, enjoy the fun of picking golden eggs, accumulate wealth, and make more like-minded friends. ———————— Come and pick up golden eggs at Tencent PP Ranch and earn your wealth! Perseverance, simple earning, and a promising future! 🎉 If you have other successful experiences in picking golden eggs, please share them in the comment area! I wish you all a happy game and full profits! https://t.me/TencentPPRanch_bot/ppp?startapp=477789 #Bitcoin#Ethereum#BinanceCoin#Tether#XRP #CorporateSocialResponsibility #EmergingMarkets#Cardano#Solana #CrossCulturalBusinessPractices #Tencent PP Ranch #Tencent PP Ranch Registration #Tencent PP Ranch Official #Free to play #Free benefits

🐓✨Tencent PP Ranch✨

@tencentppranch012 · Post #11 · 10.08.2024 г., 05:39

Tencent PP Ranch is an online simulation experience of ranch management game developed by Tencent. The initial version can give you the experience of adopting robot chickens, laying eggs, grabbing eggs, and stealing eggs, allowing you to relax through the game during a busy day. "Each egg obtained has a corresponding value" 🛒Official exclusive customer service telegram: 1️⃣t.me/TPR_005 2️⃣t.me/TPR_003 #Ethereum#Bitcoin#BinanceCoin#Tether#XRP#Cardano#Solana#Dogecoin#Polkadot#Chainlink #ENJ#ICP#XTZ#UNI#XLM#MATIC #Free rewards#Free community creation#Tencent PP Ranch Customer Service#Tencent PP Ranch Cooperation #Free USDT withdrawals #Free game resources