我正在使用python,我正在使用像这样的方法
def ping(host):
# Ping parameters as function of OS
parameters = "-n 1" if system_name().lower()=="windows" else "-c 1"
# Pinging
return system_call("ping " + parameters + " " + host) == 0
获取我正在ping的ip列表的up / down状态。有没有办法从中提取延迟?
运行此代码时的输出类似于
Ping statistics for x.x.x.x:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 50ms, Average = 50ms
x.x.x.x is down
我想说x.x.x.x已关闭,延迟= 50ms。我有一个简单的方法可以做到这一点吗?
答案 0 :(得分:0)