
Dancing with Python
By :

Files fall into two main types: text and binary. We can think of a text file as something that is humanly readable. It could be plain text with words, numbers, and punctuation. It could be an HTML file with all those, plus markup that tells us what the information means and how we should display it. The text file could contain code that you read, create, update, and extend in a programming editor. The information is likely in a Unicode encoding.
We read and write text files as strings, with newline characters separating individual lines. We might read and write the file as a list of strings or one long string.
Examples of binary files include photos, images, and videos. We don’t represent the data as characters in strings but as bytes. Each byte contains eight 0s and 1s. Instead of asking for the next line as you would for a text file, you ask for the next n bytes, for some n >...