What do you want to do with file? Only writing to it or both read and write?
'w'
, 'a'
will allow write and will create the file if it doesn't exist.
If you need to read from a file, the file has to be exist before open it. You can test its existence before opening it or use a try/except.