我想写一个程序来检测驱动器是否存在。我的代码工作,但我得到一个恼人的弹出窗口PythonW.exe当我运行程序的时候。你知道吗
import os, time, shutil, datetime, re, warnings
while True: #Loop until you close program
allDrives = re.findall(r"[A-Z]+:.*$",os.popen("mountvol /").read(),re.MULTILINE) #Find all drive letters
print("Found drives.")
for c in range(len(allDrives)):
drive = allDrives[c]
if os.path.isdir(drive) == False:
print("Hangs here.")
pass
else:
print(os.path.isdir(drive))
pathStr = drive + 'logs\\'
pathBool = os.path.exists(pathStr) #Check to see if 'logs' folder is visible
我试过用os.path.exists(path)
而不是os.path.isdir(path)
,但这也不管用。我只想找到一种方法来关闭弹出窗口。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐