To read a file into a bytearray in Python you can use the following snippet.

Sample Python

def file_to_bytes(fileName):  
    return open(fileName, "rb").read()

One thought on “How to read a file into a bytearray in Python”

Leave a Reply