Pythonw.exe:找不到驱动器弹出窗口

2024-04-25 08:44:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我想写一个程序来检测驱动器是否存在。我的代码工作,但我得到一个恼人的弹出窗口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),但这也不管用。我只想找到一种方法来关闭弹出窗口。你知道吗


Tags: path代码程序reifosexistsdrive