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 290 views
1 answer 380 views
1 answer 394 views
1 answer 181 views
2 answers 253 views
...