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

Резултати

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

Пребарај: #crdroid

当前筛选 #crdroid清除筛选
Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #153 · 12.09.2024 г., 17:15

#crDroid#diting New Version 10/09/2024: Gapped version Download Changelog: Updated to version 10.8 Note: Firmware is NOT included. Credits: Thanks to @TeamMEX_XDA for all his helps and providing dt By@Mohammadnt96

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #120 · 12.07.2024 г., 14:25

#crDroid#diting New Version 11/07/2024: Gapped version Download Changelog: crDroid v10.6 Updated to June security patch Including MiuiCamera Note: Firmware is NOT included. This is beta version. Credits: Thanks to @TeamMEX_XDA for all his helps and providing dt By@Mohammadnt96 Follow@xiaomi_12tpro_updates Join@xiaomi_12tpro_chat

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #84 · 26.02.2024 г., 21:12

#crDroid#diting New Version 25/02/2024: Gapped version Download Changelog: crDroid v10.2 SMS fixed Kernel Switched to HyperOS Used HyperOS blobs Notes: Use latest skkk twrp (v8.6) Credits: Thanks to @TeamMEX_XDA for all his helps and providing dt Discussion: Xiaomi 12T Pro crDroid

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #63 · 02.02.2024 г., 03:40

#crDroid#diting New Version 02/02/2024: Gapped version Download Changelog: crDroid v10.1 fod fixed for both touchscreens miui camera included Known Issues: Opening photo in miui camera Credits: Thanks to @TeamMEX_XDA for all his helps and providing dt Discussion: Xiaomi 12T Pro crDroid

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #17 · 11.11.2023 г., 00:57

#crDroid#Unofficial#diting#A14 Crdroid 10.0 UNOFFICIAL | Android 14 Updated: 11-11-2023 ▪️Download ▪️Support Changelog: • Initial A14 build with oss vendor Notes: Known Issues: Auto brightness must be disabled. otherwise screen will not wake after lock Fod on k50u does not work Credits: Thanks to @TeamMEX_XDA for providing dt By@Mohammadnt96 Follow@xiaomi_12tpro_updates Join@xiaomi_12tpro_chat

Xiaomi 12T Pro | K50U | Updates

@xiaomi_12tpro_updates · Post #14 · 10.11.2023 г., 01:58

#crDroid#Unofficial#diting#A13 Crdroid 9.10 UNOFFICIAL | Android 13 Updated: 05-11-2023 ▪️Download ▪️Support Changelog: • Initial Vendor OSS Build Credits: Thanks to @TeamMEX_XDA for providing dt By@Mohammadnt96 Follow@xiaomi_12tpro_updates Join@xiaomi_12tpro_chat

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #374 · 30.07.2024 г., 11:52

CrDroid - Official | Android 14 | Nothing Phone (2) 📝 Details: - Version: v10.6 - Status: #Official - Device: #Pong - Released: 30/07/24 ⬇️ Download: ROM (Vanilla) | Gapps Package 📔 Instructions: Here 🎄 Device tree : Here 📝 Changelogs : Here 🆘 Support: TG | XDA 🏷 Tags: #AOSP#ROM#CrDroid#U ✍️ Note: - Base firmware 2.6.0 is recommended - Dirty flash possible from previous july build - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu Dyavanapelli for DT Base - Hellboy for Meteoric kernel and Glyph changes - Fabian for PA Glyph Implementation 👤 Maintainer: @Ghosutox 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #353 · 15.07.2024 г., 19:46

CrDroid - Official | Android 14 | Nothing Phone (2) 📝 Details: - Version: v10.6 - Status: #Official - Device: #Pong - Released: 15/07/24 ⬇️ Download: ROM (Vanilla) | Gapps 📔 Instructions: Here 🎄 Device tree : Here 🆘 Support: TG | XDA 🏷 Tags: #AOSP#ROM#CrDroid#U ✨Changelogs: - Initial QPR3 release ✍️ Note: - Base firmware 2.6.0 is recommended - Clean flash must - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu Dyavanapelli for DT Base - Hellboy for Meteoric kernel - Fabian for PA Glyph Implementation - Testing Team 👤 Maintainer: @Ghosutox 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #296 · 15.05.2024 г., 14:18

CrDroid - Official | Android 14 | Nothing Phone (2) 📝 Details: - Version: v10.5 - Status: #Official - Device: #Pong - Released: 15/05/24 ⬇️ Download: ROM (Vanilla) | ROM Fastboot | Gapps 📔 Instructions: Here 🆘 Support: TG | XDA 💰 Donate: PayPal | BuyMeACoffee 🏷 Tags: #AOSP#ROM#CrDroid#U ✨Changelogs: - Update to CrDroid 10.5 - Added ParanoidGlyph - Fixed SMS and SIM issue ✍️ Note: - Base firmware 2.5.5 is recommended - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu Dyavanapelli for DT bring up and fix SMS issue - Hellboy017 for kernel - Pong TG Dev & Testing Team 👤 Dev: @DylanAkp 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #242 · 08.02.2024 г., 22:58

CrDroid - Official | Android 14 | Nothing Phone (2) 📝 Details: - Version: v10.2 - Status: #Official - Device: #Pong - Released: 08/02/24 ⬇️ Download: ROM (Vanilla) | Gapps 📔 Instructions: Here 💬 Support Group: Here 🏛 XDA: Here 💰 Donate: PayPal | BuyMeACoffee 🏷 Tags: #AOSP#ROM#CrDroid#U ✨Changelogs: - Initial official build - Firmware removed - Rebased on NOS 2.5.2 - Added Reverse Wireless Charging - Switched to qcom telephony - Added Glyphify (An alternative app to ParanoidGlyph I made, more to come in future updates) ⛔️ Known Issues: - Issue with reception of SMS Enabling and disabling SIM card from settings fix the issue until the next boot ✍️ Note: - Base firmware 2.5.2 is recommended - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu_Dyavanapelli for DT bring up - Hellboy017 for kernel - Przekichane for DT & vendor fixes on A13 » A14 - Pong TG Dev & Testing Team 👤 Dev: @DylanAkp 🔔 Updates: @NothingPhone2Updates 🐙 Chat: @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #226 · 05.01.2024 г., 13:53

CrDroid - Unofficial | Android 14 | Nothing Phone (2) 📝 Details: - Version : v10.x - Status: #Unofficial - Device : #Pong - Released : 04/01/24 ⬇️ Download : ROM (Vanilla) | Gapps 📔 Instructions: Here 📸 Screenshots : Here 💬 Support Group : Here 🏛 XDA : Here 💰 Donate : PayPal | BuyMeACoffee 🏷Tags : #AOSP#ROM#CrDroid#U ✨Changelogs: - Rebased on NothingOS 2.5.1 - Fixed stutters - Fixed Face Unlock - More CrDroid settings implemented - Updated to Android QPR1 (Security patch December 2023) ✍️ Note: - Base firmware 2.5.1 is recommended - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu_Dyavanapelli for DT Bringup - Hellboy017 for kernel - Przekichane for DT and Vendor fixes on A13 » A14 - Pong TG Dev and Testing Team for all help 👤 Dev : @DylanAkp 🔔 Updates : @NothingPhone2Updates 🐙 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #216 · 18.12.2023 г., 14:30

CrDroid - Unofficial | Android 14 | Nothing Phone (2) 📝 Details: - Version : v10.x - Status: #Unofficial - Device : #Pong - Released : 18/12/23 ⬇️ Download : Rom (Vanilla) | Gapps 📔 Instructions: Here 📸 Screenshots : Here 🏛 XDA : Here 💰 Donate : PayPal 🏷Tags : #AOSP#ROM#CrDroid#U ✨Changelogs: - Intitial A14 build based ✍️ Note: - Please be on NOS 2.0.4 before flashing. (Not yet tested from 2.5.1) - Report with logs if you found issues in the comment section below 🏆 Credits: - Chandu_Dyavanapelli for DT Bringup - Hellboy017 for kernel - Przekichane for DT and Vendor fixes on A13 » A14 - Snuvig for early tests - Pong TG Dev and Testing Team for all help 👤 Dev : @DylanAkp 🔔 Updates : @NothingPhone2Updates 🐙 Chat : @NothingPhone2

12
ПретходнаСтраница 1 од 2Следна