欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

python自己重启自己程序_python 自动重启本程序

发布时间:2024/9/27 python 40 豆豆
生活随笔 收集整理的这篇文章主要介绍了 python自己重启自己程序_python 自动重启本程序 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

#!/usr/local/bin/python

#-*- coding: UTF-8 -*-

####################################################################

#import os,time

#def close():

# print "程序重启!!!!"

# print time.strftime('%Y.%m.%d-%H.%M.%S')

# time.sleep(2) #3秒

# p = os.popen('11111111.bat')

# while True:

# line = p.readline();

# if '' == line:

# break

# print line

#

#

#if __name__ == '__main__':

# close()

####################################################################

import time

import sys

import os

def restart_program():

python = sys.executable

os.execl(python, python, * sys.argv)

if __name__ == "__main__":

print 'start...'

# answer = raw_input("Do you want to restart this program ? ")

# if answer.strip() in "y Y yes Yes YES".split():

# restart_program()

print u"3秒后,程序将结束...".encode("gbk")

time.sleep(3)

restart_program()

总结

以上是生活随笔为你收集整理的python自己重启自己程序_python 自动重启本程序的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。