iNTERFACEWARE Products Manual > Learning Center > Learning Python > File Reading and Writing > Opening a File |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
Before Python can access a file, it must open the file. This establishes a connection between Python and the file. To open a file, use the open() function:
open() requires two parameters:
When you specify the file name, you can specify a complete directory path:
If you specify the file name without a directory path, the current folder or directory (the one containing the Python file) is used. The mode specifies how Python will be interacting with the file. The following modes are available:
Append b to the mode if you are reading or writing a binary file. |