The with
statement is excellent for automatically opening and closing files.
with open('myfile','r+') as file:
for line in file:
if not line.isspace():
file.write(line)
The with
statement is excellent for automatically opening and closing files.
with open('myfile','r+') as file:
for line in file:
if not line.isspace():
file.write(line)