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

Резултати

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

Пребарај: #standardchartered

当前筛选 #standardchartered清除筛选
Venture Village Wall 🦄

@venturevillagewall · Post #4281 · 01.03.2025 г., 22:00

Bitcoin Predicted to Reach $200K Soon Standard Chartered's Geoff Kendrick forecasts Bitcoin will hit $200K this year and could reach $500K before Trump exits the presidency. Predictions reflect growing confidence in BTC's potential growth trajectory. #Bitcoin#Crypto#Finance#Investment#Prediction#Market#Trump#StandardChartered#DigitalAssets#GeoffKendrick

Venture Village Wall 🦄

@venturevillagewall · Post #4172 · 17.02.2025 г., 10:00

Joint Venture for HKD-Backed Stablecoin Standard Chartered, Animoca Brands, and HKT have established a joint venture to issue a HKD-backed stablecoin under Hong Kong’s new regulatory framework. This collaboration will leverage Standard Chartered Bank (Hong Kong)'s robust infrastructure and governance. More details can be found here: Animoca Brands. #Stablecoin#HongKong#Finance#Crypto#VC#StandardChartered#AnimocaBrands#HKT#Regulation

Crypto M - Crypto News

@CryptoM · Post #64926 · 10.04.2026 г., 10:15

🚀 Stablecoin Joint Venture Model Dominated by Banking Sector A joint venture in the stablecoin sector is primarily led by the banking industry. According to PANews, Standard Chartered Bank (Hong Kong) holds a 50.5% stake, making it the majority shareholder. Animoca Brands owns 37.5%, while Hong Kong Telecom indirectly holds 12% through Quality Champion Limited. This structure reflects a model where the banking sector leads, with support from technology and telecommunications. #Stablecoin#JointVenture#BankingSector#StandardChartered#AnimocaBrands#HongKongTelecom#Telecommunications#Technology#Banking#Blockchain

Venture Village Wall 🦄

@venturevillagewall · Post #3835 · 10.01.2025 г., 04:00

Russia to Sell Seized Bitcoin Assets The Russian Ministry of Finance plans to sell seized Bitcoin assets from the Infraud hacking case, starting with a batch valued at approximately $10 million. Marat Tambiev, a corrupt official, previously obtained 1,032.1 BTC from the hacker group. Read more here. #Bitcoin#Russia#Infraud#Crypto#DigitalAssets#Banking#Finance#Regulation#MiCA#Custody#StandardChartered#EU#Hacking#Seizure#MaratTambiev#CryptoNews#BTC#Blockchain#FinanceNews#News

Venture Village Wall 🦄

@venturevillagewall · Post #3974 · 24.01.2025 г., 19:00

Big Moves in Crypto Regulation News 🚀 US Senator Cynthia Lummis, a vocal Bitcoin advocate, elected Chair of the Senate Digital Assets Committee. Proposed strategic Bitcoin reserve hints at potential significant moves for Bitcoin. Meanwhile, Trump's recent crypto executive order suggests a reserve of 'seized digital assets,' increasing speculation around Bitcoin's future. 🔗 For further details, read the article here. 🔗 In additional news, the SEC has opened the door for Wall Street banks to hold crypto. 🔗 Standard Chartered forecasts Bitcoin could reach $200,000 by the end of 2025. 🔗 Japan's Central Bank raised interest rates to a 17-year high, now at 0.5%, causing ripples across markets, including crypto. #Crypto#Bitcoin#US#Regulations#SEC#InterestRates#Japan#Senate#DigitalAssets#Investment#FinancialMarkets#WallStreet#Speculation#CynthiaLummis#CryptoBanks#PanteraCapital#StandardChartered#Ethereum#AI#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4074 · 05.02.2025 г., 16:00

Crypto Market Faces Uncertainty, Analysts Warn Analysts predict further decline in the crypto market amid U.S. political uncertainty. Lack of progress on Bitcoin reserves and disappointing updates from David Sachs contribute to investor hesitance, say SkyBridge Capital's Anthony Scaramucci and QCP Capital experts. Yet, Standard Chartered forecasts Bitcoin may hit $500,000 during Trump's presidency. El Salvador recently added 11 BTC to its national Bitcoin reserve, totaling 6068 BTC. Medical firm Semler Scientific bought 871 BTC, raising its total to 3192 BTC. Additionally, Canadian company Neptune Digital Assets acquired 20 BTC, boosting their balance to 376 BTC. Meanwhile, MicroStrategy has paused further Bitcoin purchases after 12 consecutive weeks. For more details, visit: Forklog #Crypto#Bitcoin#TrumpsPresidency#SkyBridge#ElSalvador#SemlerScientific#NeptuneDigitalAssets#MicroStrategy#Investment#MarketAnalysis#QCPCapital#StandardChartered#BTC#CryptoMarket#PoliticalUncertainty#Blockchain#Investors#Reserve#Finance