How to create an empty file in Python? If the file already exists, make it empty.
I understand that you can use
open(file, "w").close() but it doesn't look very readable. Why to create open and close immediately? Are there any other options?
How to create an empty file in Python? If the file already exists, make it empty.
I understand that you can use
open(file, "w").close() but it doesn't look very readable. Why to create open and close immediately? Are there any other options?
Source: https://ru.stackoverflow.com/questions/941812/
All Articles
from io import FileIO; FileIO(file, 'w')from io import FileIO; FileIO(file, 'w')- mkkik February