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

Резултати

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

Пребарај: #floatingloss

当前筛选 #floatingloss清除筛选
Crypto M - Crypto News

@CryptoM · Post #65418 · 13.04.2026 г., 06:24

🚀 Whale Opens High-Leverage Bitcoin Short Position A large cryptocurrency holder, identified by the address starting with 0x004, has opened a Bitcoin short position with 33x leverage. According to ChainCatcher, the average price for this position is $70,745, involving 200 BTC. The position currently shows a floating loss of 10%. Earlier today, the same address closed a previous Bitcoin short position at break-even and has now re-entered the market. This marks the fifth time this month that the address has opened a short position. #Whale#Bitcoin#ShortPosition#Leverage#Cryptocurrency#BTC#ChainCatcher#FloatingLoss#Market#CryptoTrading

Crypto M - Crypto News

@CryptoM · Post #64871 · 10.04.2026 г., 06:00

🚀 Cryptocurrency Analyst Reports Significant Gains and Losses in BTC and ETH Positions Analyst @ai_9684xtpa posted on X about the latest updates on cryptocurrency positions, highlighting substantial financial movements. A user, @Jason60704294, shared in the comments section that they have set ten major goals and updated their current positions, showing a floating profit of $644,000. In the Bitcoin (BTC) short position, the user holds 2,567.49 BTC with an opening price of $71,554.61, currently experiencing a floating loss of $1.374 million. Meanwhile, the Ethereum (ETH) short position consists of 38,465.22 ETH, opened at a price of $2,248.74, resulting in a floating profit of $2.018 million. The discussion reflects the volatile nature of cryptocurrency trading, where significant gains and losses can occur based on market fluctuations. Traders often set strategic goals and adjust their positions accordingly to navigate the unpredictable market landscape. #Cryptocurrency#BTC#ETH#Bitcoin#Ethereum#Trading#ProfitLoss#MarketFluctuations#ShortPosition#FloatingProfit#FloatingLoss#CryptoAnalysis

Crypto M - Crypto News

@CryptoM · Post #64534 · 09.04.2026 г., 06:35

🚀 BTC Short Position Expanded by Strategy Counterparty On April 9, a significant adjustment was made to a BTC short position by the entity known as 'Strategy Counterparty' (0x94d3). According to BlockBeats On-chain Detection, the position was increased by 81.06 BTC, valued at approximately $5.209 million. The total position size has now reached $75.2048 million, with the average price slightly rising from $69,036.20 to $69,181.40. The liquidation price is set at $79,320.81. Currently, the position is experiencing a floating loss of approximately $1.8229 million, marking a decrease of 96.96%. This makes it the largest BTC short position on the Hyperliquid platform. It is noted that this address previously established a substantial short position against mainstream cryptocurrencies during MicroStrategy's significant BTC acquisitions last December. At that time, the position size peaked at $120 million, making it the largest BTC short on the Hyperliquid platform. #BTC#ShortPosition#StrategyCounterparty#Blockchain#OnChainDetection#Crypto#Hyperliquid#FloatingLoss#BTCShort#MarketAdjustment#Cryptocurrency

Crypto M - Crypto News

@CryptoM · Post #65374 · 13.04.2026 г., 03:00

🚀 Hyperithm's Oil Short Positions Experience Rapid Losses Analyst @ai_9684xtpa posted on X that Hyperithm's oil short positions have seen significant changes in just one day. Initially, these positions had a floating profit of $5.886 million, but they have now turned into a floating loss of $2.1 million. The CL short position, valued at $37.88 million, was opened at a price of $95.211 and currently has a floating loss of $1.402 million. Meanwhile, the BRENTOIL short position, valued at $35.17 million, was opened at a price of $95.986 and is experiencing a floating loss of $620 thousand. Currently, the address holds the largest leveraged position in Hyperliquid BRENTOIL and the third-largest leveraged position in CL. #Hyperithm#oil#shortpositions#floatingloss#CL#BRENTOIL#leveragedposition#Hyperliquid#analyst