I have a question considering python3. I am already trying for a few days to create a byte object, which looks like these:
b"'\x10\x00\x0020180425"
The first part '\x10\x00\x00 are two int16 objects which were combined. This is how I tried it to combine them:
array = [0,0,0,0,1,9,7,0,0,1,0,1]
blebytes = bytearray(array)
z = np.int16(20)
blebytes[0] = (z & 0xFF00) >> 8
blebytes[1] = (z & 0x00FF)
z = np.int16(123)
blebytes[2] = (z & 0xFF00) >> 8
blebytes[3] = (z & 0x00FF)
The second part(20180425) is just the date of today. I am trying to do this like this:
datestr = time.strftime("%Y%m%d")
for i in range(0,8):
blebytes[i+4] = np.int16(datestr[i])
print(blebytes)
But if I print my blebytes array, it looks like this:
bytearray(b'\x04\xe8\t\xf7\x02\x00\x01\x08\x00\x04\x02\x05')
What am I doing wrong? Can someone help me?