how to open and close a file in python code example
Example 1: reopen closed file python
open(f.name).read()
# prints the content of closed and reopened file
Example 2: do i need to close a file in python3 in with statement
with open('/etc/passwd') as f:
for line in f:
print(line)
# by using with statement u have no need to close the file.it auto exists after its use.