How to convert string to bytearray in Python

1 Answer

0 votes
ba = bytearray("a python", "ascii")

print(ba)

for ch in ba: print(ch)



    
'''
run:
  
bytearray(b'a python')
97
32
112
121
116
104
111
110
     
'''

 



answered Sep 15, 2020 by avibootz
...