ID EN
Pathlib

read_bytes

Python 3.11

Return the binary contents of the pointed-to file as a bytes object:

Syntax

PYTHON
Path.read_bytes()

Examples

Example 1
PYTHON
>>> p = Path('my_binary_file')
>>> p.write_bytes(b'Binary file contents')
20
>>> p.read_bytes()
b'Binary file contents'