read file python and get binary data code example Example: read binary file python file = open("sample.bin", "rb") binary_data = file. read()