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

Резултати

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

Пребарај: #qpr3

当前筛选 #qpr3清除筛选
Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #406 · 23.08.2024 г., 07:20

Bliss - Unofficial | Android 14 | Nothing Phone (2) ✍️ Details: - Version: 17.7 - Codename: #Pong - Released: 23/08/24 🔽 Download: [ GDrive ] (Sideload Build) 🆘 Support : Here ⚙️ Installation: Here 📸 Screenshots: Here ✨ Source Changelogs: Here 🔖 Tags : #ROM#AOSP#Bliss#QPR3#U ✨ Changelogs - initial build ✍️ Note: - Meteoric kernel is baked in with prepatched KSU - gapps already included 🏆 Credits - Chandu for base DT - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testers 😎 Maintainer : @Drishal 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #417 · 31.08.2024 г., 17:24

MistOS - UNOFFICIAL | A14 | Nothing Phone (2) 📔 Details: - Version: 2.8 - Codename: #Pong - Released: 31/08/2024 🔽 Download (Recovery) : Vanilla | Gapps (PL) | Gapps (L3) ⚙️ Installation: Here 📸 Screenshots: Here 🆘 Support: Telegram 🔖 Tags : #ROM#AOSP#UnOfficial#AOSP#QPR3#U#NothingPhone2 ✍️ Changelogs: - First Signed Build ✍️ Note: - Check Screenshots for features available - GKI Kernel is prepatched with KSU (Download Manager) - Clean flashing is mandatory - Flash Gapps 🏆 Credits - Chandu for base device tree & Kernel - OC'D, Miki, Unluck & Ghost for all help - Fabian & Hellboy for PA Glyph Implementation - Testers 😎 Maintainers: @AgBKartikey 🔔 Updates: @NothingPhone2Updates 💬 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #467 · 02.11.2024 г., 18:14

Project Matrixx - Official | Android 14 | Nothing Phone (2) ✍️ Details: - Version: 10.9.1 - Codename: #Pong - Released: 02/11/24 🔽 Download: [ Sourceforge ] (Sideload/Flash via orangefox recovery) 🆘 Support : Here ⚙️ Installation: Here 📸 Screenshots: Here ✨ Source Changelogs: Here 🔖 Tags : #ROM#AOSP#Official#Matrixx#QPR3#U ✨ Changelogs - Improvements to performance and system stability ✍️ Note: - Meteoric kernel is baked in with prepatched KSU - Both Gapps and Vanilla build available 🏆 Credits - Chandu for base DT - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testers 😎 Maintainer : @Drishal 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #460 · 25.10.2024 г., 12:38

Project Infinity X - Official | A14| Nothing Phone 2 (Pong) 📝 Details: - Version: v1.6 - Device: #Pong - Released: 25/10/24 ⬇️ Download: Here 📖 Changelogs: Device | Source 📔 Instructions: Here 🎄 Device tree : Here 🖼 Screenshot : Here | Here 🆘 Support: Device 🏷 Tags: #AOSP#ROM#InfinityX#U#QPR3#Official ✍️ Note: • Read changelogs • OTA available • Base firmware 2.6.0 is recommended • Dirty flash possible from previous build • Based on Qpr3 September Security Patch • Dolby Atmos available • Flash meteoric kernel for KSU support • Nik gapps recommend for vanilla version 🏆 Credits: - Chandu Dyavanapelli for DT Base - Hellboy for kernel tree - Fabian and Hellboy for Glyph Implementation 👤 Maintainer: @Ghosutox 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #440 · 24.09.2024 г., 03:43

Project Matrixx - Official | Android 14 | Nothing Phone (2) ✍️ Details: - Version: 10.8.1 - Codename: #Pong - Released: 23/09/24 🔽 Download: [ Sourceforge ] (Sideload/Flash via orangefox recovery) 🆘 Support : Here ⚙️ Installation: Here 📸 Screenshots: Here ✨ Source Changelogs: Here 🔖 Tags : #ROM#AOSP#Official#Matrixx#QPR3#U ✨ Changelogs - Add Device Extras (Wireless Powershare and USB-OTG) - Improvements to performance and system stability ✍️ Note: - Meteoric kernel is baked in with prepatched KSU - Both Gapps and Vanilla build available 🏆 Credits - Chandu for base DT - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testers 😎 Maintainer : @Drishal 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #439 · 18.09.2024 г., 14:12

Project Matrixx - Official | Android 14 | Nothing Phone (2) ✍️ Details: - Version: 10.8.0 - Codename: #Pong - Released: 18/09/24 🔽 Download: [ Sourceforge ] (Sideload Build) 🆘 Support : Here ⚙️ Installation: Here 📸 Screenshots: Here ✨ Source Changelogs: Here 🔖 Tags : #ROM#AOSP#Official#Matrixx#QPR3#U ✨ Changelogs - switched to user build - added systemui restart in power menu - stability improvements ✍️ Note: - Meteoric kernel is baked in with prepatched KSU - Both Gapps and Vanilla build available 🏆 Credits - Chandu for base DT - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testers 😎 Maintainer : @Drishal 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #429 · 11.09.2024 г., 10:17

Project Infinity X - Official | A14| Nothing Phone 2 (Pong) 📝 Details: - Version: v1.5 - Device: #Pong - Released: 11/09/24 ⬇️ Download: Here 📖 Changelogs: Device | Source 📔 Instructions: Here 🎄 Device tree : Here 🖼 Screenshot : Here | Here 🆘 Support: Device 🏷 Tags: #AOSP#ROM#InfinityX#U#QPR3#Official ✍️ Note: • Read changelogs • Base firmware 2.6.0 is recommended • Dirty flash possible from previous build • Based on Qpr3 September Security Patch • Dolby Atmos available • Flash meteoric kernel for KSU support • Nik gapps recommend for vanilla version 🏆 Credits: - Chandu Dyavanapelli for kernel & DT Base - Fabian and Hellboy for Glyph Implementation 👤 Maintainer: @Ghosutox 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #425 · 10.09.2024 г., 09:09

Project Matrixx - Official | Android 14 | Nothing Phone (2) ✍️ Details: - Version: 10.8.0 - Codename: #Pong - Released: 10/00/24 🔽 Download: [ Sourceforge ] (Sideload Build) 🆘 Support : Here ⚙️ Installation: Here 📸 Screenshots: Here ✨ Source Changelogs: Here 🔖 Tags : #ROM#AOSP#Official#Matrixx#QPR3#U ✨ Changelogs - added charging control ✍️ Note: - Meteoric kernel is baked in with prepatched KSU - Both Gapps and Vanilla build available 🏆 Credits - Chandu for base DT - Hellboyfor Meteoric kernel - Fabian and Hellboyfor PA Glyph Implementation - Testers 😎 Maintainer : @Drishal 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #416 · 31.08.2024 г., 11:58

Project Matrixx - Official | Android 14 | Nothing Phone (2) ✍️ Details: - Version: 10.7.3 - Codename: #Pong - Released: 24/08/24 🔽 Download: [ Sourceforge ] (Sideload Build) 🆘 Support : Here ⚙️ Installation: Here 📸 Screenshots: Here ✨ Source Changelogs: Here 🔖 Tags : #ROM#AOSP#Official#Matrixx#QPR3#U ✨ Changelogs - switch to Dolby ✍️ Note: - Meteoric kernel is baked in with prepatched KSU - Both Gapps and Vanilla build available 🏆 Credits - Chandu for base DT - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testers 😎 Maintainer : @Drishal 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #410 · 27.08.2024 г., 07:03

Project Infinity X - Official | A14| Nothing Phone 2 (Pong) 📝 Details: - Version: v1.4 - Device: #Pong - Released: 27/08/24 ⬇️ Download: Here 📔 Instructions: Here 🎄 Device tree : Here 🖼 Screenshot : Here | Here 🆘 Support: Device 🏷 Tags: #AOSP#ROM#InfinityX#U#QPR3#Official ✍️ Note: • Initial official release • Base firmware 2.6.0 is recommended • Clean flash mandatory • Based on Qpr3 August Security Patch • Dolby Atmos available • Flash meteoric kernel for KSU support • Nik gapps recommend for vanilla version 🏆 Credits: - Chandu Dyavanapelli for kernel & DT Base - Fabian and Hellboy for Glyph Implementation 👤 Maintainer: @Ghosutox 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #407 · 23.08.2024 г., 15:18

Project Matrixx - Official | Android 14 | Nothing Phone (2) ✍️ Details: - Version: 10.7.2 - Codename: #Pong - Released: 23/08/24 🔽 Download: [ Sourceforge ] (Sideload Build) 🆘 Support : Here ⚙️ Installation: Here 📸 Screenshots: Here ✨ Source Changelogs: Here 🔖 Tags : #ROM#AOSP#Official#Matrixx#QPR3#U ✨ Changelogs - update to 10.7.2 ✍️ Note: - Meteoric kernel is baked in with prepatched KSU - Both Gapps and Vanilla build available 🏆 Credits - Chandu for base DT - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testers 😎 Maintainer : @Drishal 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #403 · 18.08.2024 г., 17:09

Project Matrixx - Official | Android 14 | Nothing Phone (2) ✍️ Details: - Version: 10.7.1 - Codename: #Pong - Released: 18/08/24 🔽 Download: [ Sourceforge ] (Sideload Build) 🆘 Support : Here ⚙️ Installation: Here 📸 Screenshots: Here ✨ Source Changelogs: Here 🔖 Tags : #ROM#AOSP#Official#Matrixx#QPR3#U ✨ Changelogs - update to 10.7.1 ✍️ Note: - Meteoric kernel is baked in with prepatched KSU - Both Gapps and Vanilla build available 🏆 Credits - Chandu for base DT - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testers 😎 Maintainer : @Drishal 🔔 Updates : @NothingPhone2Updates 💬 Chat : @NothingPhone2

123•••56
ПретходнаСтраница 1 од 6Следна