Python Object-Oriented Programming by Steven F. Lott Dusty Phillips

Python Object-Oriented Programming by Steven F. Lott Dusty Phillips

Author:Steven F. Lott, Dusty Phillips
Language: eng
Format: epub
Tags: COM051000 - COMPUTERS / Programming / General, COM051360 - COMPUTERS / Programming Languages / Python, COM051210 - COMPUTERS / Programming / Object Oriented
Publisher: Packt
Published: 2021-06-28T07:36:40+00:00


We could also supply the value "a" as a mode argument, to append to the end of the file, rather than completely overwriting existing file content.

These files with built-in wrappers for converting bytes to text are great, but it'd be awfully inconvenient if the file we wanted to open was an image, executable, or other binary file, wouldn't it?

To open a binary file, we modify the mode string to append "b". So, "wb" would open a file for writing bytes, while "rb" allows us to read them. They will behave like text files, but without the automatic encoding of text to bytes. When we read such a file, it will return bytes objects instead of str, and when we write to it, it will fail if we try to pass a text object.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.