Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Adapted and simplified from Franck Albinet's exercises available here. Also presented by NSRC at APRICOT 2018.

...

In essence to handle files in Python, you first need to open a file (even if it does not exist yet)




Code Block
languagepy
linenumberstrue
python f = open('log/my_first_file.log', 'w')


the open function takes as argument: file name 'log/my_first_file.log' (relative or full path) and mode: read, write, ...

...