python讓程序重復(fù)運(yùn)行的方法:1、報(bào)錯(cuò)后,重新啟動(dòng)【.py】文件,繼續(xù)執(zhí)行;2、重復(fù)執(zhí)行本【.py】文件中的內(nèi)容;3、異常調(diào)用函數(shù)本身。
python讓程序重復(fù)運(yùn)行的方法:
方法一:
報(bào)錯(cuò)后,重新啟動(dòng).py文件,繼續(xù)執(zhí)行
while 1: run_ticker = 'python ticker.py' run_depth = 'python depth.py' run_depth_pct = 'python depth_pct.py' run_trade = 'python trade.py' os.system(run_depth_pct)方法二:
重復(fù)執(zhí)行本.py文件中的內(nèi)容
os.execvp(sys.executable, [sys.executable] sys.argv)或
python = sys.executable # 獲取當(dāng)前執(zhí)行python os.execl(python, python, *sys.argv) # 執(zhí)行命令方法三:
異常調(diào)用函數(shù)本身
def restart(): try: fun() except eoferror as e: print(e) finally: restart()相關(guān)學(xué)習(xí)推薦:python視頻教程