How to read a file into a bytearray in Python

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()

Please Share us:
Please rate this snippet

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

Leave a Reply