Aug-12-2021, 07:12 AM
I don't really understand what you want to do. We don't know what
Data
is in your example (str, bytearay, list. something else?)spam = bytearray(b'0P\x14}\x04\xf8\xff3') data = [f"{byte:02x}" for byte in spam] print(f'Full Data: {data}') start=0 length = 4 data = [f"{byte:02x}" for byte in spam[start:start + length]] print(f'Partial data: {data}')
Output:Full Data: ['30', '50', '14', '7d', '04', 'f8', 'ff', '33']
Partial data: ['30', '50', '14', '7d']
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs