figure - figure - the windows calc exe program opened in notepad since every different type of binary file must be handled in its own waythis book will not go into reading and writing raw binary files directly fortunatelymany modules make working with binary files easier--you will explore one of themthe shelve modulelater in this the pathlib module' read_text(method returns string of the full contents of text file its write_text(method creates new text file (or overwrites an existing onewith the string passed to it enter the following into the interactive shellfrom pathlib import path path('spam txt' write_text('helloworld!' read_text('helloworld!these method calls create spam txt file with the content 'helloworld!the that write_text(returns indicates that characters were written to the file (you can often disregard this information the read_text(call reads and returns the contents of our new file as string'helloworld!keep in mind that these path object methods only provide basic interactions with files the more common way of writing to file involves using the open(function and file objects there are three steps to reading or writing files in python call the open(function to return file object call the read(or write(method on the file object close the file by calling the close(method on the file object we'll go over these steps in the following sections