Oct-15-2020, 06:05 PM
it works
, thank to you all for the tips

invalid syntax (BEGINNER)
|
Oct-15-2020, 06:05 PM
it works
![]()
Oct-16-2020, 01:45 PM
In addition to what GOTO10 said about (over)write vs append, there is also one more thing you need to read and understand. Please read here!
Especially this part: The main advantage of using a with statement is that it makes sure our file is closed without paying attention to how the nested block exits. Please have a look at this code snippet: with open('test.txt', 'w') as file_test: # The file is open within this code block file_test.write('Hello') #Here, the file is already closed, no need to call close() method if file_test.closed: print('File is already closed!') |
|