How to convert a list to bytes in Python

1 Answer

0 votes
lst = [1, 2, 3, 4, 5]

arr = bytes(lst)

print(arr)


 
 
 
'''
run:
 
b'\x01\x02\x03\x04\x05'
 
'''

 



answered Apr 25, 2021 by avibootz

Related questions

...