【发布时间】:2014-06-17 23:26:01
【问题描述】:
【问题讨论】:
【问题讨论】:
这是一个与操作系统无关的版本:
try:
file = open("thefile.txt", "r+")
except IOError:
print "File is open!"
编辑添加您的问题与check if a file is open in Python重复
【讨论】:
如果你已经有一个指向文件的指针:
if f.closed:
print('file is closed')
【讨论】: