新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
python怎么讓程序重復運行
python讓程序重復運行的方法:1、報錯后,重新啟動【.py】文件,繼續(xù)執(zhí)行;2、重復執(zhí)行本【.py】文件中的內(nèi)容;3、異常調(diào)用函數(shù)本身。
創(chuàng)新互聯(lián)建站長期為上千家客戶提供的網(wǎng)站建設(shè)服務,團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為三河企業(yè)提供專業(yè)的網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè),三河網(wǎng)站改版等技術(shù)服務。擁有十余年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。
python讓程序重復運行的方法:
方法一:
報錯后,重新啟動.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)
方法二:
重復執(zhí)行本.py文件中的內(nèi)容
os.execvp(sys.executable, [sys.executable]+sys.argv)
或
python = sys.executable # 獲取當前執(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)學習推薦:python視頻教程
網(wǎng)頁名稱:python怎么讓程序重復運行
URL地址:http://fisionsoft.com.cn/article/cjohes.html