Correct option is D
In Python, the rb+ mode opens a file in binary format for both reading and writing. This mode allows you to read existing content and write new data to the file without truncating it.
Important Key Points:
- r stands for read.
- b stands for binary.
- + indicates both reading and writing are allowed.
- Using rb+ ensures the file is treated as a binary file, which is essential for non-text files like images, executables, or serialized data.
Knowledge Booster:
- (a) ab: Opens the file in binary append mode (writing only, at the end of the file).
- (b) wb: Opens the file in binary write mode (truncates the file if it exists).
- (c) r+: Opens the file in text mode for both reading and writing (not suitable for binary files).