Open the file in bytes mode, read it, and close the file.
>>> p = Path('my_binary_file') >>> p.write_bytes(b'Binary file contents') 20 >>> p.read_bytes() b'Binary file contents'
pathlib/Path.read_bytes
Path.read_bytes