Skip to content Skip to sidebar Skip to footer

Zip File To Bytes Python 3

I want to store a zip file in a postgres database. The column is type bytea When attempting to get the bytes of a json file, or a csv file I can use this with open(filename, encodi

Solution 1:

If you want to read the JSON file as bytes you should open the file in binary mode:

with open(filename, 'rb') as file_data:
    bytes_content = file_data.read()

Post a Comment for "Zip File To Bytes Python 3"