[Python] U8,U16,U32 representation in python

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    I have two questions and they both are inter-related.

    My first question is: As for example, I have to declare few U8 variables, U16 and U48 and then have to pass the values to them. After passing the values, I have to covert them into a binary (one binary-all of them combined). I don't know how to perform this task How to define U8, U16 and U32 in python(in binary). I know struct as a module. But when I write

    ex=binascii.hexlify(struct.pack("I",1))


    it returns b'01000000' instead of returning 01000000. Is there any other way to do it(I need it in U8 format)

    My second question is:

    How can disintegrate U8 into 2MSbits and 6LSbits

    Continue reading...

Compartilhe esta Página