扫码关注官方订阅号
我要测试一批ip响应时间,类似ping的响应时间,要求毫秒级的。可以设置毫秒级超时,如 >500ms 就为不合格,继续测试下一个。Python、PHP脚本都可以
#coding=utf8 import os ip_list=['192.168.0.1','192.168.0.2','192.168.0.3','192.168.0.106'] for each in ip_list: a=os.popen('ping -n 1 %s'%each).read().decode('gbk') b=a.find('=') c=a.find('ms') time=a[b+7:c] try: if int(str(time))>=500: print 'time >= 500ms' else: print each+' : '+time+'ms' except Exception as e: print 'lost'
记得给赞哟
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
记得给赞哟