python重启程序 重新运行脚本

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

定义一个重启函数

#主程序
print('restart...')
            restart_program()
原文地址:https://www.cnblogs.com/mrfri/p/8558306.html