How to open a binary file in append mode with Python?

PythonServer Side ProgrammingProgramming

"Binary" files are any files where the format isn't made up of readable characters. Binary files can range from image files like GIFs, audio files like MP3s or binary document formats like Word or PDF. To open files in binary append mode, when specifying a mode, add 'ab' to it.

For example

 f = open('my_file.mp3', 'ab')
file_content =

Above code opens my_file.mp3 in binary append mode and stores the file content in file_content variable.

Published on 21-Dec-2017 17:58:06