Answers for "open binary file in python"

4

read binary file python

file = open("sample.bin", "rb")
binary_data = file. read()
Posted by: Guest on April-15-2021
3

write binary file in python

file = open("sample.bin", "wb")
COPYfile.write(b"This binary string will be written to sample.bin")
COPYfile.close()
Posted by: Guest on January-08-2021
0

reading binary file

with open("myfile", "rb") as f:
    byte = f.read(1)
    while byte != b"":
        # Do stuff with byte.
        byte = f.read(1)
Posted by: Guest on April-18-2021

Python Answers by Framework

Browse Popular Code Answers by Language