Files

To open a local file in Python we call the built-in open() function. This takes a number of arguments, but the most commonly used are:

  • file: the path to the file. This is required.
  • mode: read, write, append and binary or text. This is optional, but we recommend always specifying it for clarity. Explicit is better than implicit.
  • encoding: If the file contains encoded text data, which encoding to use. It's often a good idea to specify this. If you don't specify it, Python will choose a default encoding for you.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset