Python·100 questions

How to correctly work with files in binary mode?

Answer
open(path, 'rb') for reading bytes.
For writing: 'wb'.
Do not specify encoding in binary mode.
For large files — use chunks.
For hashes — hashlib.
Was this answer helpful?

More questions in this topic

Related questions from other topics