import win32file
import os.path
def is_used(file_name):
#print(type(file_name))
if os.path.exists(file_name):
print("found")
#判断文件是否已打开
try:
vHandle = win32file.CreateFile(file_name, win32file.GENERIC_READ, 0, None, win32file.OPEN_EXISTING, win32file.FILE_ATTRIBUTE_NORMAL, None)
return "文件未打开"
except:
return "文件已打开"
finally:
try:
win32file.CloseHandle(vHandle)
except:
pass
else:
print("Not found")