xxxxxxxxxx
def read_file_bytes(filename):
with open(filename, 'rb') as f:
return f.read()
xxxxxxxxxx
with open("myfile", "rb") as f:
byte = f.read(1)
while byte:
# Do stuff with byte.
byte = f.read(1)
xxxxxxxxxx
# Open the file in binary mode
with open("file_path", "rb") as file:
# Read the bytes from the file
file_bytes = file.read()
# Print the content of the file as bytes
print(file_bytes)