#!/usr/bin/env Python3
# -*- coding: utf-8 -*-
# @Software: PyCharm
# @virtualenv:workon
# @contact: contact information
# @Desc:Code descripton
__author__ = '未昔/AngelFate'
__date__ = '2019/9/28 17:34'
import os
import socket
import time
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
if s:
s.connect((ip,int(port)))
s.shutdown(2)
print('%d is open' % port)
print('休眠10秒')
time.sleep(20)
except:
print('%d is down' % port)
os.system('python 111.py') ##启动程式
return False
if __name__ == '__main__':
while True:
IsOpen('127.0.0.1',3306)
time.sleep(5)
这个必须点赞👍