Problem Statement
When should you use binary mode 'rb' or 'wb'?
Explanation
Binary mode reads and writes raw bytes. Use it for non-text data like images, archives, or custom binary protocols.
Text mode decodes bytes to strings using an encoding and may translate newlines. That is ideal for human-readable text.
Code Solution
SolutionRead Only
with open('photo.jpg','rb') as f:
buf=f.read(1024)