open file as binary python code example
Example 1: write binary file in python
file = open("sample.bin", "wb")
COPYfile.write(b"This binary string will be written to sample.bin")
COPYfile.close()
Example 2: read binary file python
file = open("sample.bin", "rb")
binary_data = file. read()