【发布时间】:2017-12-17 19:37:34
【问题描述】:
我想如果找到 txt 并等待程序。但是程序找到 txt 并继续这导致错误我该怎么办?
import time
import os
hard_drive = 'D:\\sifreler.txt' , 'E:\\sifreler.txt' , 'F:\\sifreler.txt' , 'G:\\sifreler.txt' , 'I:\\sifreler.txt'
hard_drive1 = hard_drive
while True:
for i in hard_drive1:
try:
sifre = open(i, "r")
sifree = sifre.readline()
if sifree == "8da0dd52e2ee6c04528ede0cd84e6770":
print("True")
explorer1 = os.system("start explorer.exe")
time.sleep(1)
except FileNotFoundError:
print("File Not Found")
explorer1 = os.system("TASKKILL /F /IM explorer.exe")
time.sleep(1)
except PermissionError:
print()
【问题讨论】:
-
你遇到了什么故障?
-
File Not Found File Not Found True File Not Found File Not Foundprogram if True 等待程序。不要继续 FileNotFoundError -
在
D:/、E:/、G:/或H:/中找不到文件sifreler.txt。 -
我不明白你的意思是“我想要 `sifre = open(i, "r") 写 i 而不是 F:/sifreler.txt”。您试图用这段代码解决的全部问题是什么?听起来您缺少一些使其适合您的目的的逻辑。
-
如果您需要包含更多详细信息,请将它们编辑到帖子中,以便其他人可以理解上下文。如果你不能向大家清楚地解释问题,那么帮助你将非常困难。
标签: python python-3.x