May 2019
Beginner
528 pages
29h 51m
English
Python views a text file as a sequence of characters and a binary file (for images, videos and more) as a sequence of bytes. As in lists and arrays, the first character in a text file and byte in a binary file is located at position 0, so in a file of n characters or bytes, the highest position number is n – 1. The diagram below shows a conceptual view of a file:

For each file you open, Python creates a file object that you’ll use to interact with the file.
Every operating system provides a mechanism to denote the end of a file. Some represent it with an end-of-file marker (as in the preceding ...
Read now
Unlock full access