I'm trying to convert a string / int list to a .bin bytes format final file:
final_data = ['3247', '5146', '6971', '-8192', '8192', '11192']
final_data2 = [int(i) for i in final_data]
arr = bytes(final_data2)
with open("data.bin", "wb") as fh:
fh.write(arr)
But I'm getting this error:
ValueError: bytes must be in range(0, 256)
How to proceed knowing that I have negative numbers and numbers larger than 256 ?