【发布时间】:2021-07-17 19:08:59
【问题描述】:
#code 工作,但无法访问的部分不工作,请帮助我
os.chdir(r'C:\Users\berka\OneDrive\Masaüstü\Masaüstü\melon')
while True:
files = os.listdir("./")
for file in files:
if os.path.isfile(file) and file !="melon.py" and file != "fileOrganiser.bat" and file != "fileOrganiser.vbs":
ext = (file.split(".")[-1]).lower()
if ext in image_formats:
shutil.move(file,"images/"+file)
elif ext in audio_formats:
shutil.move(file,"audio/"+file)
elif ext in video_formats:
shutil.move(file,"videos/"+file)
elif ext in docs_formats:
shutil.move(file,"docs/"+file)
else:
shutil.move(file,"others/"+file)
#ıt 在此之后不起作用
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
print(voices[1].id)
engine.setProperty('voice',voices[1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
#你知道如何解决
#我尝试做一个语音助手,结果成功了。然后我尝试在windows打开的时候运行它,我发现了这样一个代码,但是我遇到了这个问题。
【问题讨论】:
-
while True是一个无限循环。对于要执行的代码,您需要以某种方式结束循环。 -
你知道如何结束吗?
-
我什至不知道循环是干什么用的。
-
while True循环的目的是什么?你为什么把它放在那里? -
我试着做一个语音助手,结果成功了。然后我尝试在windows打开的时候运行,发现有这样的代码,但是遇到了这个问题。
标签: python unreachable-code unreachable-statement