I want to convert back from bytes the list of tuples I had.
lst is a list of tuples (x,y), x and y are integer.
The code of converting to bytes is:
b = b''.join([(x << 16 | (y & 2 ** 16 - 1)).to_bytes(6, 'big') for x, y in lst])
Now I want to write function that get that b variable and convert him back to that list.
How can I do it?
while(b!=b''):
Z=b[:6]
Q=Z[4:]
A=int.from_bytes(Q,'big')
w=int.from_bytes(z,'big')
w=w>>16
lst.append((w,A))
b=b[6:]
for example for the list ([(1, 1), (2, 2)], [(1, 1), (2, 1)], [(2, 1)], [(1, 2), (2, 1)]) convert to bytes.
The code that I wrote that convert bytes back to the list, I get the list:
([(1, 1), (1, 2)], [(1, 1), (1, 1)], [(1, 1)], [(1, 2), (1, 1)])