0

How can we say that our file is open or not and our file is closed or not?

In C language, when we open any file we get file discriptor of that file, but in python ther is a long statement we get.

24th Feb 2018, 9:42 AM
Sagar Parkale
Sagar Parkale - avatar
1 Odpowiedź
+ 1
In python, if there is some error in opening the file, you automatically get a IOError. And you can always do this to handle the error in your way : try : file = open("a.txt","w+") except IOError : print("Error Opening File") And for checking whether the file is closed, we have the .closed member... if file.closed: print("File I/O Operation Complete")
24th Feb 2018, 10:10 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar