Hi im trying to parse this bit of code its hex returned from a device. I would like it to give me the number after the x that i specify in this case between 3 and 7 characters…
Im expecting 01
Temphex = [b'\x01\x03\x04\x18X\xa8\xb0\x03']
search_Temphex = Temphex.find("x",3,7)
print(search_Temphex)
this is my error:
in
search_Temphex = Temphex.find(“x”,3)
AttributeError: ‘list’ object has no attribute ‘find’
There is no find
method on a list. Temphex
is a list with one string element.
Temphex is a list (no .find() method). The first and only element of Temphex (Temphex[0]) is a byte() object, with several methods (dir(byte()). Also you can use slicing in bytes() or iterate trhought each element of Temphex[0].
Thank you … yes i got this to work for me…
value = b’\x01\x03\x04\xD8\xa8\xb0\x03’
split = [value[i] for i in range (0, len(value))]
print (split[3])
output is 216, it converted D8 hex into decimal 216