我正在为Windows 7创建一个Python 3程序,以便在CD上搜索安装可执行文件的通用名称并运行它。我试过使用多个os.path.exists,但是当它找到正确的文件时,它会打印出它找不到其他可能的文件名。 请帮忙!在Python中搜索某些文件的其他驱动器3
if os.path.exists("D:/autorun.exe"):
os.startfile("D:/autorun.exe")
else:
print("Failed Attempt!")
if os.path.exists("D:/Install.exe"):
os.startfile("D:/Install.exe")
else:
print("Failed Attempt!")
if os.path.exists("D:/AutoRun.exe"):
os.startfile("D:/AutoRun.exe")
else:
print("Failed Attempt!")
if os.path.exists("D:/install.exe"):
os.startfile("D:/install.exe")
else:
print("Failed Attempt!")
我真的不知道该怎么做! –
添加了有问题的代码! –
你能告诉我一个如何使用它的例子吗? –