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

Резултати

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

Пребарај: #nasdaq100

当前筛选 #nasdaq100清除筛选
NEWS 鏈新聞-ABMedia

@abmedia_news · Post #24345 · 04.05.2026 г., 11:01

【💰 交易市場|為搶進 SpaceX、OpenAI 與 Anthropic IPO 熱潮,那斯達克與標普放寬標準】 #SpaceX#OpenAI#Nasdaq100 標普與那斯達克 5 月修改規則,縮短 SpaceX 等巨頭入選指數的等待期。 那斯達克增設快軌機制,市值前 40 名企業掛牌 15 天即可空降成為成分股。市場擔憂被動資金過早湧入,導致股價在定價前遭到嚴重扭曲。 📍閱讀全文: https://abmedia.io/nasdaq-sp500-listing-rules-relaxed 📍 訂閱鏈新聞頻道:https://linktr.ee/abmedia.io

Crypto M - Crypto News

@CryptoM · Post #65223 · 12.04.2026 г., 04:14

🚀 Sky Co-Founder Rune Faces Losses in Leveraged Oil and S&P 500 Positions Sky co-founder Rune's leveraged positions have recently experienced significant losses. According to Odaily, data from Hyperbot indicates that Rune's sevenfold leveraged short position on the Nasdaq 100 was closed 16 hours ago. Currently, he holds long positions valued at approximately $518,000, including a 20-fold leveraged long position in WTI crude oil futures and a sevenfold leveraged position in Brent oil. Additionally, Rune maintains a 20-fold leveraged short position on the S&P 500, valued at $159,000. At present, all of Rune's positions are in a loss state, with the total value dropping to around $678,000, reflecting a floating loss of approximately $61,000 and an investment return rate of -22.68%. Rune initially entered these positions last month when oil prices were rising, achieving a floating profit exceeding $1 million. However, recent fluctuations and declines in oil prices have turned these positions from profit to loss. #Sky#Rune#LeveragedTrading#OilFutures#SP500#Nasdaq100#FinancialLoss#WTICrude#BrentOil#Investing#SKY

Crypto M - Crypto News

@CryptoM · Post #64545 · 09.04.2026 г., 07:14

🚀 Whale Adjusts Investment Strategy Across Major Markets On April 9, a significant investor, known for substantial positions in three major markets, closed all long positions in WTICRUDE and BRENTOIL, according to BlockBeats. Previously, the combined holdings in these oils exceeded $14.1 million, resulting in a loss of over $3.9 million upon closure. Following this, the investor opened a short position in WTICRUDE at an average price of $92.3, with a current scale of $9.3 million and a liquidation price of $117.6. This adjustment has led to the following main positions across the three markets: In U.S. stocks, the investor holds long positions in the Nasdaq 100 and S&P 500, with a scale of $38.1 million and an unrealized profit of $430,000. In the cryptocurrency market, the investor maintains a long position in Bitcoin, with a scale of $12.05 million at an average price of $6,540, resulting in an unrealized profit of $30,000. In commodities, the investor's short position in WTI crude oil stands at $9.3 million, with an unrealized loss of $290,000. The address associated with these transactions is 0x8af700ba841f30e0a3fcb0ee4c4a9d223e1efa05. #Investment#MarketStrategy#WTICrude#BrentOil#USStocks#Nasdaq100#SP500#Bitcoin#Cryptocurrency#Commodities#Trading#Blockchain#BlockBeats#BTC

PRICE ACTION EXPERT

@priceactionexpert · Post #7905 · 23.11.2024 г., 08:14

https://x.com/priceactiongann/status/1830819785975955483 #nifty#geometry#banknifty New Course Book! ✅Market movements through the lens of advanced Geometric concepts. ✅Multidimensional and Spherical Time concepts of Trading with our upcoming course (book), ✅This innovative book dives deep into the concept of time-related trading, blending advanced geometric principles with practical markets Exploring Triangles, Squares, and Circles. ❤️🙏❤️ #stocks#stockmarket#gann#trading#time#gold#silver#xauusd#SPX500#DowJones#NASDAQ100

PRICE ACTION EXPERT

@priceactionexpert · Post #7723 · 03.09.2024 г., 04:08

https://x.com/priceactiongann/status/1830819785975955483 #nifty#geometry#banknifty New Course Book! ✅Market movements through the lens of advanced Geometric concepts. ✅Multidimensional and Spherical Time concepts of Trading with our upcoming course (book), ✅This innovative book dives deep into the concept of time-related trading, blending advanced geometric principles with practical markets Exploring Triangles, Squares, and Circles. ❤️🙏❤️ #stocks#stockmarket#gann#trading#time#gold#silver#xauusd#SPX500#DowJones#NASDAQ100