2014-06-17 55 views

回答

1

这里是一个与操作系统无关的版本:

try: 
    file = open("thefile.txt", "r+") 
except IOError: 
    print "File is open!" 

编辑补充你的问题是check if a file is open in Python

0

重复如果你已经有一个指针文件:

if f.closed: 
    print('file is closed')