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 слични објави

Пребарај: #web2

当前筛选 #web2清除筛选
Nomis | Onchain Reputation Protocol

@nomis_protocol · Post #552 · 25.11.2024 г., 15:51

🎟Get superpower with your Scores within Hybrid Savings—tons of tailored offers for Score holders and much more! Hybrid Savings is a unique aggregator of exclusive deals that combines #WEB2 & #WEB3 in one convenient format of a Telegram Mini App. There you may find the best promotions, promo codes, and discounts! 🤔How can you access Hybrid Savings’ promo codes and other offers? 1) Visit Hybrid Savings via Partners or ScoreFront pages 2) Go to “Wallet” page 3) Click “Connect TON Wallet” 4) Enjoy exclusive deals! 💎 Now you can also enjoy all the ScoreFront benefits via Hybrid Savings right in the app—check the integration yourself using the button below!

Hashtags

Nomis | Onchain Reputation Protocol

@nomis_protocol · Post #513 · 31.10.2024 г., 12:02

🎟Yo dawg I herd u like benefits so we put a benefit in yo Score so u can be rewarded while u rewarded!Meet dozens of rewarding offers in Hybrid Savings offer on ScoreFront💎 Hybrid Savings is a unique aggregator of exclusive deals that combines #WEB2 & #WEB3 in one convenient format of a Telegram Mini App. There you may find the best promotions, promo codes, and discounts! 🤔How can you access Hybrid Savings’ promo codes and other offers? 1) Visit Hybrid Savings via Partners or ScoreFront pages 2) Go to “Wallet” page 3) Click “Connect TON Wallet” 4) Enjoy exclusive deals! Explore the offer details and leverage you Score by accessing best deals using the button below!

Hashtags

DWF Labs Broadcast

@Dwflabs · Post #97 · 14.12.2022 г., 09:30

While blockchain-based technologies have many qualities that set them apart from other computing paradigms, one of their primary value propositions is the generation of cryptographic truth. Amidst the market uncertainty, cryptographic truth is taking on greater prominence in setting the stage for a new competitive battleground for #Web2 and #Web3 applications centered around the type of trust-minimized guarantees offered to users. Now, it is up to users, developers, entrepreneurs, and forward-looking companies to begin building and adopting trust-minimized, quality protocols and products with real long-term viability. As we continue to empower development, expansion and #innovation in this space, we recognise the importance of building a world powered by #truth. This is the new standard. Full read here.

DWF Labs Broadcast

@DWFLabs · Post #201 · 09.02.2023 г., 00:01

[2 Feb-8 Feb] DWF Crypto Snapshot Our latest #crypto report by our Managing Partner Andrei Grachev is up. In this week's round up 💫 💠 Bitcoin #NFTs? It’s More Likely Than You Think 💠 Federal Rate Hikes Fuel #Bitcoin Price Sentiments 💠Renewed NFT Interest Drives #Trading And Lending On Popular #Marketplaces 💠History Comes To Life As Woodstock Takes To The #Metaverse 💠Western Financial Institutions Push #Crypto Prices With Spot Inflows 💠Japan Aims To Revitalize Its #Economy With Web3 #Innovation 💠Major #Web2 Companies Starts Hiring To Bolster #Web3 Capability Full readhere. Missed last week's snapshot? Read here. Follow us on Medium here. Stay up-to-date on the latest DWF Labs updates: Website| Twitter | Linkedin | Telegram

Crypto M - Crypto News

@CryptoM · Post #64885 · 10.04.2026 г., 06:54

🚀 Tria Integrates Aptos Network for Enhanced Global Transactions Tria, a non-custodial financial operating system, has announced the integration of its global trading engine with the Aptos network. According to ChainCatcher, this integration allows over 500,000 users across more than 150 countries to directly access and trade Aptos assets. Users can now perform cross-chain exchanges and asset interactions within a single application without the need for cross-chain bridges. The collaboration aims to leverage Aptos's sub-second confirmation and parallel execution technology to provide users with a seamless transaction experience. Additionally, it seeks to further connect traditional finance, Web2, and on-chain infrastructure. #Tria#AptosNetwork#GlobalTransactions#NonCustodial#FinancialOperatingSystem#CrossChainExchanges#AssetInteractions#Blockchain#Web2#OnChainInfrastructure#Aptos#Crypto#DecentralizedFinance#Fintech#APT