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 | ||||
---|---|---|---|---|
| ||||
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, ...
...