from ping3 import ping, verbose_ping if __name__ == '__main__': # 简单用法 ping地址即可,超时会返回None 否则返回耗时,单位默认是秒 second = ping('www.baidu.com') print('it took {} second'.format(second)) 这个基础用法特别简单,感觉代码已经非常清晰了。 注意 成功的时候,默认返回的是秒...
此时你可以使用verbose_ping函数,下面是代码示例: host="google.com"# 要测试的主机地址# 可设置 count 控制 Ping 次数verbose_ping(host,count=4)# 执行详细 Ping 测试,发送4个Ping请求 1. 2. 3. 4. 这段代码调用verbose_ping函数,它会输出每次 Ping 的详细信息,包括响应时间等。你可以通过调整count参数设...
fromping3importping,verbose_ping# 单次 Ping 测试response_time=ping('www.google.com')ifresponse_timeisnotNone:print(f"Ping www.google.com 需时:{response_time*1000:.2f}ms")else:print("Ping 请求超时!")# 多次 Ping 测试print("多次 Ping 测试:")verbose_ping('www.google.com',count=4) 1....
ping3有两个模块,分别是ping和verbose_ping,其中ping模块被用作批量ping,ping模块再ping通目的IP地址/域名时会返回延迟时间,如果ping不通则返回None。这个返回特性适合用来做批量ping测试。而verbose_ping则和shell使用ping3时候的返回相同 fromping3importping,verbose_ping>>>baidu_name='baidu.com'>>>google_n...
from ping3 import ping, verbose_ping import time from datetime import datetime def ping_tool(host,src_addr): second = ping(host,src_addr=src_addr) return second print(__name__)#测试内置变量__name__用 if __name__ == '__main__': ...
>>>fromping3importping,verbose_ping>>>ping('example.com')# Returns delay in seconds.0.215697261510079666# `0.0` returned means the delay is lower than the precision of `time.time()`.>>>ping('not.exist.com')# If host unknown (cannot resolve), returns False.False>>>ping("224.0.0.0")#...
Cancel Create saved search Sign in Sign up {{ message }} jarhainx / python-ping3 Public Notifications You must be signed in to change notification settings Fork 1 Star 0 Code Issues Pull requests Actions Projects Security Insights ...
-q --quiet 安静模式 -I --interface 网卡接口 (默认是路由接口) -V --verbose 详细模式 -D --debug 调试信息 -z --bind 绑定 ctrl+z到 ttl (默认为目的端口) -Z --unbind 取消绑定 ctrl+z键 --beep 对于接收到的每个匹配数据包蜂鸣声提示 模式 选择 default mode TCP // 默认模式是 TCP -0 -...
(不影响-l)-l、 --监听Bind并监听传入连接-k、 --保持打开状态在监听模式下接受多个连接-n、 --nodns不通过DNS解析主机名-t、 --telnet回答telnet谈判-u、 --udp使用udp而不是默认TCP--sctp使用sctp而不是默认TCP-v、 --verbose设置详细程度(可以多次使用)-w、 --wait连接超时-z零I/O模式,仅报告连接...
可以看下接上trust的接口时,流量是否很大,此时设备cpu、内存等是否正常;或者trust到untrust的安全策略...