Convert String To Byte Array in Python In this post, We will learn how to convert a string into a byte array in python programming language. def string_to_byte_array(string): byteArray = [] for c in string: byteArray = byteArray.append(ascii(c)) print (string_to_byte_array("Rozgardesh")) Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.