DEV Community

Discussion on: How to use Python to Create Files?

Collapse
 
peter279k profile image
peter279k

Just notice that it should call f.close() method after creating/writing file.

Collapse
 
iceorfiresite profile image
Ice or Fire
Collapse
 
migueltorrealba profile image
Miguel Torrealba

That's right, so it saves adding .close (), as it will run automatically.

Thread Thread
 
fabiocaccamo profile image
Fabio Caccamo

Even better, simply use python-fsutil library.