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

Резултати

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

Пребарај: #intelligentassets

当前筛选 #intelligentassets清除筛选
Go! Announcements

@gorwachain_announcements · Post #1076 · 06.11.2025 г., 15:45

🎉 Wake up Assets! 🎉 ⚡️🚀 TODAY’S MISSIONS ✅ Check-in on the Go! App → app.gosmartchain.ai to keep your streaks + XP alive. ✅ Use the new @goagenticbot → t.me/goagenticbot - Simulate your first intelligent real-world asset (car, watch, home, artwork…) - Your assets now think, learn, and talk back. Share your creation in the TG groups and get 5 $GSMC for each share! 💬 Try it: t.me/goagenticbot→ use #AgenticAsset#GoRWA#AI#RWA ✅ Health Hero check-in: @healthheroapp_bot → /start → /log or /workout (+40 XP w/photo) ✅ Zealy Leaderboard: (New one going live today! https://zealy.io/cw/gorwachain/leaderboard/2623fee8-db99-41c9-a059-2a24c54858d3) — every action earns points toward early airdrops. ✅ TaskOn Quest: Start Now: https://taskon.xyz/quest/652417804 — complete the new Go! missions. ✅ Post your best content on X: https://x.com/gorwachain @ us! #crypto#RWA#AI#DeFi#wellness#fitness#agentic#health 🤖 Meet the Go! Agentic Bot 🧱 Simulate a Sentient Asset: bring a car, watch, or collectible to life in seconds. 🙋🏽‍♂️ Pledge Your Asset: mint your real item as an intelligent twin on Go! Marketplace. 🏢 Pledge for a Company: refer a business with ≥ $1 M in tokenizable assets → earn a referral reward through our Ambassador Program. 💰 Early pledgers will hold the most valuable early assets on the Go! Marketplace and share in transaction value when their assets trade details dropping soon. 💎 The Intelligent Asset Economy Go! and Health Hero are building a world where every action = ownership. Go! powers the AI + RWA layer the brain of the Intelligent Asset Economy. Health Hero turns your wellness, discipline, and consistency into tokenized rewards. $GSMC is the gas + governance token that fuels it all. Earn $GSMC by checking in daily, completing Zealy + TaskOn missions, using the Agentic Bot, and staying active in the community. 🌍 Mission & Vision Recap “We’re building the world’s first Intelligent Asset Economy, where every person and every asset can think, earn, and grow together.” 💫 Our Values: • Faith in People: Human energy is the most valuable asset. • Intelligence in Action AI + Blockchain should serve real lives. • Wellness = Wealth, A healthy world is a wealthier world. • Community: We win together. 🦾 Bonus Missions 🏗 Node Owners: Own a Go! Agentic Node → nodes.gosmartchain.ai 🎁 XP to Token Conversion: Health Hero XP → Tokenized Rewards soon 💰 🧩 Ambassador Program: Refer companies with RWA portfolios and earn rewards: https://whitepaper.gosmartchain.ai/go-programs/ambassador-program 🔥 In Short This week’s energy = participate + create + share. Make your first asset sentient. Show it off. Tag #GoRWA#Agentic#IntelligentAssets. Let’s Go! 🌍💪

Go! Announcements

@gorwachain_announcements · Post #1072 · 04.11.2025 г., 16:24

🎉 NEW WEEK, NEW MAGIC: The Age of Sentient Assets Begins 🎉 While the market’s waking up, the Go! Fam is way ahead, you’re not just holding tokens, you’re creating living, intelligent assets. The Agentic Sprint continues, and the newest mission is pure 🔥. ⚡️🚀 TODAY’S MISSIONS (New + Core) ✅ Check-in on the Go! App → app.gosmartchain.ai to keep your streaks + XP alive. ✅ Use the new @goagenticbot → t.me/goagenticbot - Simulate your first intelligent real-world asset (car, watch, home, artwork…) - Share your Sentient Card to Telegram or X → use #AgenticAsset#GoRWA#AI#RWA ✅ Health Hero check-in: @healthheroapp_bot → /start → /log or /workout (+40 XP w/photo) ✅ Zealy Leaderboard: (New one going live today! https://zealy.io/cw/gorwachain) — every action earns points toward early airdrops. ✅ TaskOn Quest: Start Now: https://taskon.xyz/quest/652417804 — complete the new Go! missions. ✅ Post your best content on X: https://x.com/gorwachain @ us! #crypto#RWA#AI#DeFi#wellness#fitness#agentic#health 🤖 Meet the Go! Agentic Bot Your assets now think, learn, and talk back. 💬 Try it: t.me/goagenticbot 🧱 Simulate a Sentient Asset: bring a car, watch, or collectible to life in seconds. 🙋🏽‍♂️ Pledge Your Asset: mint your real item as an intelligent twin on Go! Marketplace. 🏢 Pledge for a Company: refer a business with ≥ $1 M in tokenizable assets → earn a referral reward through our Ambassador Program. 💰 Early pledgers will hold the most valuable early assets on the Go! Marketplace and share in transaction value when their assets trade details dropping soon. 💎 The Intelligent Asset Economy Go! and Health Hero are building a world where every action = ownership. Go! powers the AI + RWA layer the brain of the Intelligent Asset Economy. Health Hero turns your wellness, discipline, and consistency into tokenized rewards. $GSMC is the gas + governance token that fuels it all. Earn $GSMC by checking in daily, completing Zealy + TaskOn missions, using the Agentic Bot, and staying active in the community. 🌍 Mission & Vision Recap “We’re building the world’s first Intelligent Asset Economy, where every person and every asset can think, earn, and grow together.” 💫 Our Values: • Faith in People: Human energy is the most valuable asset. • Intelligence in Action AI + Blockchain should serve real lives. • Wellness = Wealth, A healthy world is a wealthier world. • Community: We win together. 🦾 Bonus Missions 🏗 Node Owners: Own a Go! Agentic Node → nodes.gosmartchain.ai 🎁 XP to Token Conversion: Health Hero XP → Tokenized Rewards soon 💰 🧩 Ambassador Program: Refer companies with RWA portfolios and earn rewards: https://whitepaper.gosmartchain.ai/go-programs/ambassador-program 🔥 In Short This week’s energy = participate + create + share. Make your first asset sentient. Show it off. Tag #GoRWA#Agentic#IntelligentAssets. Let’s Go! 🌍💪