Python os.system 反复打开程序
Python os.system open again and again program
我想打开一个程序然后连续打印"explorer opened":
import os
while True:
os.system("start explorer.exe")
print("explorer opened")
一次又一次open explorer.exe
,我不想用 break 语句来 `While'。
这是我对你想从你的问题中得到什么的最佳猜测
import os
already_ran = False
os.system("start explorer.exe")
while True:
#If not already ran run the explorer
if already_ran == False:
os.system("start explorer.exe")
already_ran = True #now that is is ran do not run it again
print("explorer opened")
上面的代码将 运行 explorer.exe
一次,然后将无限期地打印 explorer opened
我想打开一个程序然后连续打印"explorer opened":
import os
while True:
os.system("start explorer.exe")
print("explorer opened")
一次又一次open explorer.exe
,我不想用 break 语句来 `While'。
这是我对你想从你的问题中得到什么的最佳猜测
import os
already_ran = False
os.system("start explorer.exe")
while True:
#If not already ran run the explorer
if already_ran == False:
os.system("start explorer.exe")
already_ran = True #now that is is ran do not run it again
print("explorer opened")
上面的代码将 运行 explorer.exe
一次,然后将无限期地打印 explorer opened