r read w create file or truncate to zero length for write a append; open or create file for writing at end-of-file rb binary read wb binary write ab binary append r+ open file for update, read and write w+ truncate to zero length or create file for update a+ open or create file for update, writing at EOF rb+ binary file for update, read and write wb+ truncate to zero length or create binary file for update ab+ append; open or create binary file for update, writing at EOF