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

Пребарај: #mobilegaming

当前筛选 #mobilegaming清除筛选
DeckForge Announcement

@deckforge_official · Post #358 · 10.12.2025 г., 12:01

⏸ The Official DeckForge Gameplay Trailer is Here! Our official gameplay trailer is finally here — your first true glimpse into the chaos, beauty & raw power of the DeckForge multiverse. 🔵Where explosive combos ignite, 🔵where Bosses rise from the Void, 🔵where Jokers are forged, broken, reborn & where Genesis begins. This trailer marks the start of a new chapter — one that you will shape. 👀 Watch the trailer. Feel the energy. Step into the Forge. Share your thoughts in the comments — we’re reading every single one. Stay Forged! 🔥 #DeckForge#MobileGaming#GameplayReveal Join the DeckForge Community: 🌐YouTube𝕏Twitter🎮Discord 👉Chat👉Announcements👉DeckForge

DeckForge Announcement

@deckforge_official · Post #351 · 08.12.2025 г., 16:51

▶️DeckForge x RuStore Conference Recap RuStore Mobile Conference has officially wrapped — and it was incredible. 🔵Over 1,000+ industry leaders, studios, publishers and creators gathered under one roof 🔵Our showcase zone was packed all day — tons of gameplay sessions, powerful feedback & new connections with top experts across CIS & Asia 🔵RuStore shared big insights on the future of their platform and expansion into Asian markets — and we’re thrilled to grow alongside them as one of the most anticipated cross-platform titles of 2026 🔵This year, RuStore held its first-ever awards for the best mobile apps and games. Dozens of titles were recognized as the industry’s top performers But we know one thing for sure: next year, DeckForge is taking its place on that stage! Now it’s time to get back to the forge — polishing the upcoming release, preparing holiday events & crafting something truly special for our players. Stay Forged 🔥 #DeckForge#RuStore#GameDev#MobileGaming Join the DeckForge Community: 🌐YouTube𝕏Twitter🎮Discord 👉Chat👉Announcements👉DeckForge

GAMEFEST.UZ

@gamefestuz · Post #270 · 02.04.2026 г., 09:11

🎮 KATTA YANGILIK: TapNation — Game Fest 2026 markazida! Tayyor turing, geymerlar! Dunyoning eng yirik mobil o‘yin nashriyotlaridan biri bo‘lgan TapNation rasman Game Fest 2026 festivalida ishtirok etishini e’lon qiladi! 🚀 Bu shunchaki tadbir emas, bu mobil o‘yinlar olamidagi inqilobiy tajriba bo‘ladi. Biz bilan birga o‘yin sanoatining kelajagiga sho‘ng‘ing! ————————— 🎮 BIG NEWS: TapNation Takes Center Stage at Game Fest 2026! Get ready, gamers! We are thrilled to officially announce that TapNation, one of the world’s leading mobile game publishers, will be lighting up Game Fest 2026! 🚀 This isn’t just an event; it’s an immersive journey into the future of mobile gaming. Join us as we push the boundaries of innovation and dive deep into the next generation of play #TapNation#GameFest2026#MobileGaming#GamingCommunity#Gamedev#UzbekistanGaming#NewGames2026

Bounty Hunters 💎

@trustedairdropsss · Post #655 · 01.03.2021 г., 06:12

Unlock unlimited fun & winning at Rummy24. Download the App Now👉https://rummy24.sng.link/Averc/fcz2/lcft . . . #Rummy24#RummyApp#PlayRummy#UnlimitedFun#PlayRummy#onlinerummy#cardsgame#mobilegames#mobilegaming#mobilegame#cardgames#onlinegame#play#skills#win