with open('table.html', 'w'): pass
table_file = open('table.html', 'w')
table_file.write('<!DOCTYPE html><html><body>')
This will open the table.html file two times, and your file will also not be closed.
If you use with , then:
with open('table.html', 'w') as table_file:
table_file.write('<!DOCTYPE html><html><body>')
c automatically closes the file after the area.
:
table_file = open('table.html', 'w')
table_file.write('<!DOCTYPE html><html><body>')
table_file.close()
.