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

Пребарај: #stepn

当前筛选 #stepn清除筛选
Block Daily Dance & Podcast/Space List

@blockdancenews · Post #188 · 27.03.2022 г., 12:52

🔦 Block Daily Dance (3月27日): We are Information Aggregator of BlockChain & Web3.0, running by DAO. 我们是由社区驱动的区块链 & Web3 信息聚合平台。 ✈️Telegram Channel:https://t.me/blockdancenews 📒Notion:https://bit.ly/3LopaUj 🌊 Defi: $STG代币研究报告 https://twitter.com/BTCdayu/status/1507767610787917828 🛰 Layer 1 / L2 / 跨鏈: 从哪里开始学ETH2.0? https://twitter.com/nake13/status/1507725710622076928 👾 Metaverse/Gamefi: 3月27日 #STEPN 数据分析日记 https://twitter.com/0xBigPineapple/status/1507875809440186369 「GameFi」:DAO Farmer游戏玩法详解及分析 https://twitter.com/qiaoyunzi1/status/1507967619319873539 从5个层次思考,Web2游戏过渡到Web3游戏意味着什么? https://www.odaily.news/post/5176983 🏙 DAO : dao4ever的Mirror系列已经汇总 https://twitter.com/ShawnMelUni/status/1507977131929702405 🎙 播客/AMA/Talks/活动: https://bit.ly/3HuwSJQ 🔍 链上数据/行情分析: 周末资金继续度假 成交放缓 解析500天欧美亚时区BTC走势 2022-03-27 https://twitter.com/Phyrex_Ni/status/1508039613960491014 BTC数据日报-2022年03月26日 https://twitter.com/Pro_0xBi/status/1507912736352587782 🧰 综合: Alkimiya 项目介绍 https://twitter.com/fishkiller/status/1507938266468683780 怎样从0E到BAYC,8个我认为最重要的小诀窍 https://twitter.com/MrFryR/status/1507567357400518662 DelphiDigital相关文章一览 https://twitter.com/FinanceYF3/status/1508033529640271877 周末日常长推聊感悟,从BTC到DeFi到NFT。 https://twitter.com/William11Chan/status/1507892715333115915 foresight news周末荐读:一览 zkSync 生态版图,无聊猿母公司 Yuga Labs 为何值 40 亿美元? https://foresightnews.pro/article/detail/1460 https://t.me/blockdancenews

Hashtags

Crypto currents | Money, Games, News.

@cryptocurrentsglobal · Post #3030 · 07.02.2025 г., 11:16

🔤🔤🔤🔤🔤 StepMania is officially live! 🥂 More steps – more coins, guys! StepMania is not just a pedometer but a move-to-earn app where every step is rewarded, new records keep you motivated, and the community fuels the excitement. How does StepMania work? 🌎Pedometer – track your activity and set personal records! 🥇Leaderboards – compete with friends and other users to reach the top! 💬Community – share your achievements, exchange tips, and stay motivated! 🏳️Plus, awesome giveaways! Gadgets, subscriptions, and other bonuses for active users right from the start! Stop tapping! With StepMania, walking is not just healthy but also rewarding. Step up and earn. Walk to Earn Join the game👉link #Stepn#Stepmania#Earn Crypto Currents | Get referrals | Buy Telegram Stars

❤️Vanilla Finance Closes Pre-Seed Investment Round ✔️ Singapore, November 26, 2024 – Vanilla Finance, the leading exchange by trading volume on #Telegram, has announced the successful closure of its Pre-Seed investment round. Spearheaded by industry giants like Paper Ventures, UOB Ventures, and ABCDE Labs, the round also attracted notable participants such as #HTX Ventures, #Ocular, #Openspace, #Y2 Ventures, and angel investors from #STEPN, #Scroll, #XAI, and more. 🔫A Game-Changer in the Digital Asset Space Since its launch, #VanillaFinance has made waves, amassing over $8 billion in USDT trading volume within just 60 days. This meteoric rise is further validated by winning the prestigious #Binance MVB Season 8, a recognition of the platform’s cutting-edge solutions and market leadership. 👏Visionary Growth and User-Centric Innovation With fresh funding and institutional backing, Vanilla Finance is on a mission to redefine crypto trading by: • Simplifying User Experience: Introducing intuitive, secure features tailored for both novices and experts. • Expanding Offerings: Launching a spot market, with a focus on meme trading pairs, and rolling out features like a meme creator platform, staking products, and futures trading. • Regional Focus: Targeting Southeast Asia and APAC with localized services, multilingual support, and integration with regional payment systems. 💰Institutional Confidence in a Bright Future The involvement of strategic investors highlights Vanilla Finance’s potential. A UOB Ventures spokesperson praised the platform’s innovative approach, while Danish Chaudhry of Paper Ventures noted, “Vanilla Finance’s expansion aligns perfectly with the Southeast Asia and APAC markets’ untapped opportunities in digital finance.” 📖Building a Next-Generation Ecosystem Beyond trading, Vanilla Finance is creating an ecosystem that prioritizes community engagement and innovation. With its unique approach to meme trading and user-focused features, the platform is poised to set a new benchmark in digital asset trading. ✈️The Future Starts Here: Vanilla Finance is committed to serving the next 100 million users, shaping a more inclusive, engaging, and forward-thinking crypto landscape. ❤️ Join Vanilla mini-app now and get as much $CONE as you can before the airdrop!