SoFunction
Updated on 2024-10-29

python implementation of automatic restart of this program

This article example describes the python implementation of automatic restart of this program. Shared for your reference. The specific implementation method is as follows:

#!/usr/local/bin/python
#-*- coding: UTF-8 -*-
####################################################################
# python automatically restarts this program
####################################################################
#import os,time
#def close():
# print "Program restart !!!!"
#  print ('%Y.%m.%d-%H.%M.%S')
# (2) #3 seconds
#  p = ('')
#  while True:
#    line = ();
#    if '' == line:
#      break
#    print line
#if __name__ == '__main__':
#  close()
####################################################################
import time
import sys
import os
def restart_program():
  python = 
  (python, python, * )
if __name__ == "__main__":
  print 'start...'
#  answer = raw_input("Do you want to restart this program ? ")
#  if () in "y Y yes Yes YES".split():
#    restart_program()
  print u"In three seconds, the program will end...".encode("gbk")
  (3)
  restart_program()

The running effect is shown below:

I hope that what I have described in this article will help you in your Python programming.