How to get array of bytes from a string in Python

1 Answer

0 votes
string = "Python programming"

arr = bytearray(string, 'utf-8')

print(arr)
 
 
 
 
 
'''
run:
 
bytearray(b'Python programming')
 
'''

 



answered Apr 25, 2021 by avibootz

Related questions

1 answer 285 views
1 answer 291 views
1 answer 381 views
1 answer 394 views
1 answer 182 views
2 answers 255 views
...