发布时间:2019-07-14 10:00:28编辑:auto阅读(1502)
使用Ulipad编辑的
#! /usr/bin/env python
#coding=utf-8
#############
import subprocess
import time
ip="10.210.202."
#############
def aa():
ks=int(time.time()) #记录开始时间
num1=num2=0
for i in range(1,254):
ips=ip+str(i)
ret=subprocess.call("ping -n 1 -w 1 %s " % ips)
if ret == 0:
print (ips,"+++++++++++++Online ")
num1=num1+1
else:
# print (ips,"-------------Offline")
num2=num2+1
js=int(time.time()) #记录结束时间
print("time(秒):",js-ks,"s") #打印并计算用的时间,s秒
print("ON_line:",num1," OFF_line:",num2)
while True:
aa()
hd=input("是否继续【Y/N】:")
try:
if hd=="Y" or hd=="y":
pass
except :pass
if hd=="N" or hd=="n":
print("Goodbye!......")
time.sleep(3)
break
效果图如下:
上一篇: python 爬取mm信息
下一篇: python的 ConfigParser
47481
45784
36781
34306
28953
25587
24433
19604
19094
17624
5456°
6039°
5555°
5630°
6556°
5368°
5368°
5874°
5848°
7161°