Hello! There is data in hex: 0x000407d10001 it is necessary to take only the necessary part from hex: these are 01 and 07d1 .

You can do this:

 c = '0x000407d10001' c[12:] c[6:-4] 

You need to do this all in a binary bin. The task is to ensure that the operation is performed as quickly as possible, I think if this operation will be performed in bin, then its speed will be higher.



    1 answer 1

    This can be done using masks. Suppose you need to view the value of 1 byte and 3 + 4 bytes (as in your task). Making masks

     n=0x000407d10001 m1=0xFF m34=0xFFFF0000 print "Byte 1: %X" % (n & m1) print "Bytes 3-4: %X" % ((n & m34) >> 16)