Table of Contents
show
File Object
- Once a file is successfully opened, a file object is returned. Using this file object, one can easily access different types of information related to the file
- This information can be obtained by reading values of specific attribute of the file
Example
fp = open("new_file","w")
s = "Welcome All!!"
fp.write(s)
print("Check file is closed ?:",fp.closed)
fp.close()
print("And Now, file is closed:",fp.closed)
print("Mode in which file is open:",fp.mode)
print("Name of the file:",fp.name)
Output
Check file is closed ?: False
And Now, file is closed: True
Mode in which file is open: w
Name of the file: new_file
Views: 0