首页 > 技术文章 > python重启程序 重新运行脚本

mrfri 2018-03-13 16:28 原文

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

定义一个重启函数

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

 

推荐阅读