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 187 views
1 answer 199 views
1 answer 298 views
1 answer 319 views
1 answer 93 views
2 answers 153 views
...