python重启程序 重新运行脚本

#重启程序
def restart_program():
  python = sys.executable
  os.execl(python, python, * sys.argv)

定义一个重启函数

#主程序
print('restart...')
            restart_program()

 

posted @ 2018-03-13 16:28  Mrfri  阅读(23713)  评论(1编辑  收藏  举报