Linux shell编程学习笔记66:ping命令 超详细的选项说明
0 前言
网络信息是电脑网络信息安全检查中的一块重要内容,Linux和基于Linux的操作系统,提供了很多的网络命令,今天我们研究最常用的ping命令。
1 ping命令 的功能、格式和选项说明
1.1 ping命令 的功能
简单来说, ping 命令 会使用 ICMP(Internet Control Message Protocol) 传输协议,向网络主机发出要求回应的信息,若网络主机的网络功能没有问题,就会回应该信息,从而得知该主机运作正常。
具体来说,ping 命令使用 ICMP 协议的强制ECHO_REQUEST数据报从主机或网关引出 ICMP ECHO_RESPONSE。ECHO_REQUEST数据报 (''pings'') 都有一个 IP 和 ICMP 标头,后跟一个结构体 timeval,然后是用于填充数据包的任意数量的 ''pad'' 字节。
ping 命令常用于检测 网络中的另一台主机或路由器是否可访问。
1.2 Linux中的ping命令支持ipV6吗?
- 在基于 Debian 的 Linux 发行版(包括 Ubuntu)上,您可以使用 ping6 命令强制 ping 使用 IPv6 而不是 IPv4。
- 在基于 Red Hat 的发行版(如 CentOS)和基于 Arch Linux 的发行版(如 Manjaro)上,使用带 -6 选项的 ping 命令来强制 IPv6。
1.3 Linux中的ping命令与Windows中的ping命令相同吗?
Linux中的ping命令与Windows中的ping命令在功能上可以说是相同的,但是两者在某些方面存在不同。例如,在默认情况下,Linux 下的ping会连续发送包,而Windows的ping命令 仅发送 4 个包。
Windows 中的ping命令格式如下:
C:\Users\purpleendurer>ping用法: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS][-r count] [-s count] [[-j host-list] | [-k host-list]][-w timeout] [-R] [-S srcaddr] [-c compartment] [-p][-4] [-6] target_name选项:-t Ping 指定的主机,直到停止。若要查看统计信息并继续操作,请键入 Ctrl+Break;若要停止,请键入 Ctrl+C。-a 将地址解析为主机名。-n count 要发送的回显请求数。-l size 发送缓冲区大小。-f 在数据包中设置“不分段”标记(仅适用于 IPv4)。-i TTL 生存时间。-v TOS 服务类型(仅适用于 IPv4。该设置已被弃用,对 IP 标头中的服务类型字段没有任何影响)。-r count 记录计数跃点的路由(仅适用于 IPv4)。-s count 计数跃点的时间戳(仅适用于 IPv4)。-j host-list 与主机列表一起使用的松散源路由(仅适用于 IPv4)。-k host-list 与主机列表一起使用的严格源路由(仅适用于 IPv4)。-w timeout 等待每次回复的超时时间(毫秒)。-R 同样使用路由标头测试反向路由(仅适用于 IPv6)。根据 RFC 5095,已弃用此路由标头。如果使用此标头,某些系统可能丢弃回显请求。-S srcaddr 要使用的源地址。-c compartment 路由隔离舱标识符。-p Ping Hyper-V 网络虚拟化提供程序地址。-4 强制使用 IPv4。-6 强制使用 IPv6。
1.4 ping命令的格式
与我们之前学的大多数linux命令不同,ping命令不支持--help选项。
我们可以使用ping 或 ping -?命令获取ping命令的格式信息。
[purpleendurer @ bash ~] ping
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface][-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos][-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option][-w deadline] [-W timeout] [hop1 ...] destination
Usage: ping -6 [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface][-l preload] [-m mark] [-M pmtudisc_option][-N nodeinfo_option] [-p pattern] [-Q tclass] [-s packetsize][-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline][-W timeout] destination
[purpleendurer @ bash ~] ping -?
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface][-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos][-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option][-w deadline] [-W timeout] [hop1 ...] destination
Usage: ping -6 [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface][-l preload] [-m mark] [-M pmtudisc_option][-N nodeinfo_option] [-p pattern] [-Q tclass] [-s packetsize][-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline][-W timeout] destination
[purpleendurer @ bash ~]
1.4.1支持ipV4的ping命令格式
ping [-aAbBdDfhLnOqrRUvV64] [-c 完成次数] [-i 间隔秒数] [-I 网络界面]
[-m mark] [-M pmtudisc_option] [-l 前置载入] [-p 范本样式] [-Q tos]
[-s 数据包大小] [-S sndbuf] [-t 存活数值] [-T 间间戳选项]
[-w 退出前等待秒数] [-W 执行前等待秒数] [hop1 ...] 目标主机名称或IP地址
1.4.2 支持ipV6的ping命令格式
ping -6 [-aAbBdDfhLnOqrRUvV] [-c 完成次数] [-i 间隔秒数] [-I 网络界面]
[-l 前置载入] [-m mark] [-M pmtudisc_option]
[-N nodeinfo_option] [-p 范本样式] [-Q tclass] [-s 数据包大小]
[-S sndbuf] [-t 存活数值] [-T 间间戳选项] [-w 退出前等待秒数]
[[-W 执行前等待秒数] 目标主机名称或IP地址
1.5 ping命令选项说明
ping命令的选项非常多,而且不同版本linux 提供的ping命令选项也不尽相同。
参数 | 描述 |
---|---|
-a | Audible ping. 可听到的ping |
-A |
|
-b | Allow pinging a broadcast address. 允许对广播地址进行ping |
-B |
|
-c count |
|
-d |
|
-F flow label |
|
-f |
|
-i interval |
|
-I interface address |
|
-l preload |
|
-L |
|
-n |
|
-p pattern |
|
-Q tos |
|
-q |
|
-R |
|
-r |
|
-s packetsize |
|
-S sndbuf |
|
-t ttl | Set the IP Time to Live. 设置IP的生存时间(TTL) |
-T timestamp option |
|
-M hint |
|
-U |
|
-v | Verbose output. 详细输出 |
-V | Show version and exit. 显示版本并退出 |
-w deadline |
|
-W timeout |
|
2 ping命令实例
2.1 ping -a g.cn
[purpleendurer @ bash ~] ping -a g.cn
PING g.cn (114.250.67.34) 56(84) bytes of data.
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=1 ttl=116 time=4.41 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=2 ttl=116 time=4.36 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=3 ttl=116 time=4.34 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=4 ttl=116 time=4.38 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=5 ttl=116 time=4.34 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=6 ttl=116 time=4.36 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=7 ttl=116 time=4.36 ms
^C
--- g.cn ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6007ms
rtt min/avg/max/mdev = 4.342/4.368/4.414/0.041 ms
[purpleendurer @ bash ~]
1.2 ping -A g.cn :自适应 ping g.cn
[purpleendurer @ bash ~] ping -A g.cn
PING g.cn (114.250.70.34) 56(84) bytes of data.
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=1 ttl=117 time=5.04 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=2 ttl=117 time=4.76 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=3 ttl=117 time=4.76 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=4 ttl=117 time=4.77 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=5 ttl=117 time=4.76 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=6 ttl=117 time=4.81 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=7 ttl=117 time=4.77 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=8 ttl=117 time=4.79 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=9 ttl=117 time=4.98 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=10 ttl=117 time=4.81 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=11 ttl=117 time=4.77 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=12 ttl=117 time=4.78 ms
^C
--- g.cn ping statistics ---
12 packets transmitted, 12 received, 0% packet loss, time 2210ms
rtt min/avg/max/mdev = 4.760/4.820/5.045/0.123 ms, ipg/ewma 200.918/4.862 ms
[purpleendurer @ bash ~]
可以看到,ping -A 返回个信息的速度明显快于 ping -a。
1.3 ping -b g.cn:使用广播方式ping g.cn
[purpleendurer @ bash ~] ping -b g.cn
PING g.cn (114.250.70.34) 56(84) bytes of data.
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=1 ttl=117 time=4.83 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=2 ttl=117 time=4.81 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=3 ttl=117 time=4.80 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=4 ttl=117 time=4.76 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=5 ttl=117 time=4.80 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=6 ttl=117 time=4.86 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=7 ttl=117 time=4.80 ms
^C
--- g.cn ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6011ms
rtt min/avg/max/mdev = 4.766/4.813/4.862/0.095 ms
[purpleendurer @ bash ~]
1.4 ping -B g.cn
[purpleendurer @ bash ~] ping -B g.cn
PING g.cn (114.250.67.34) from 172.25.109.185 : 56(84) bytes of data.
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=1 ttl=116 time=4.01 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=2 ttl=116 time=4.36 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=3 ttl=116 time=3.94 ms
^C
--- g.cn ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 3.943/4.108/4.364/0.197 ms
[purpleendurer @ bash ~]
1.5 ping -c 2 g.cn:向g.cn发送2个ICMP包
[purpleendurer @ bash ~] ping -c 2 g.cn
PING g.cn (114.250.70.34) 56(84) bytes of data.
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=1 ttl=117 time=4.82 ms
64 bytes from 114.250.70.34 (114.250.70.34): icmp_seq=2 ttl=117 time=4.82 ms--- g.cn ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 4.822/4.822/4.822/0.000 ms
[purpleendurer @ bash ~]
1.6 ping -d g.cn
[purpleendurer @ bash ~] ping -d g.cn
PING g.cn (114.250.67.34) 56(84) bytes of data.
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=1 ttl=116 time=3.95 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=2 ttl=116 time=3.97 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=3 ttl=116 time=3.92 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=4 ttl=116 time=3.89 ms
64 bytes from 114.250.67.34 (114.250.67.34): icmp_seq=5 ttl=116 time=3.92 ms
^C
--- g.cn ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 3.896/3.933/3.976/0.062 ms
[purpleendurer @ bash ~]
1.7 ping -f g.cn:洪水 ping g.cn (只有超级用户才能使用此选项)
[purpleendurer @ bash ~] ping -f g.cn
PING g.cn (114.250.67.34) 56(84) bytes of data.
ping: cannot flood; minimal interval allowed for user is 200ms
[purpleendurer @ bash ~] sudo ping -f g.cn
PING g.cn (114.250.65.34) 56(84) bytes of data.
.^C
--- g.cn ping statistics ---
5304 packets transmitted, 5303 received, 0% packet loss, time 28698ms
rtt min/avg/max/mdev = 5.285/5.390/12.965/0.268 ms, pipe 2, ipg/ewma 5.411/5.371 ms
[purpleendurer @ bash ~]
1.8 ping -i 2 -c 3 g.cn:间隔2秒钟向g.cn发送3个ICMP包
[purpleendurer @ bash ~] ping -i 2 -c 3 g.cn
PING g.cn (114.250.65.34) 56(84) bytes of data.
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=1 ttl=117 time=5.49 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=2 ttl=117 time=5.38 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=3 ttl=117 time=5.40 ms--- g.cn ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 5.389/5.428/5.491/0.096 ms
[purpleendurer @ bash ~]
1.9 ping -q g.cn :以静默方式ping g.cn
[purpleendurer @ bash ~] ping -q g.cn
PING g.cn (114.250.65.34) 56(84) bytes of data.
^C
--- g.cn ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7010ms
rtt min/avg/max/mdev = 5.386/5.410/5.453/0.023 ms
[purpleendurer @ bash ~]
命令返回的信息除了启动时和完成时的总结行外,不显示任何内容。
1.10 ping -s 99 g.cn:以99个字节ping g.cn
[purpleendurer @ bash ~] ping -s 99 g.cn
PING g.cn (114.250.65.34) 99(127) bytes of data.
107 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=1 ttl=117 time=5.43 ms
107 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=2 ttl=117 time=5.44 ms
107 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=3 ttl=117 time=5.39 ms
^C
--- g.cn ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 5.396/5.427/5.449/0.088 ms
[purpleendurer @ bash ~]
1.11 ping -t 16 g.cn: 以TTL 值为16向g.cn发送ICMP包
[purpleendurer @ bash ~] ping -t 16 g.cn
PING g.cn (114.250.65.34) 56(84) bytes of data.
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=1 ttl=117 time=5.39 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=2 ttl=117 time=5.40 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=3 ttl=117 time=5.38 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=4 ttl=117 time=5.39 ms
^C
--- g.cn ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 5.382/5.393/5.407/0.090 ms
[purpleendurer @ bash ~]
1.12 ping -T <时间戳> g.cn:设置特殊的 IP 时间戳选项来ping g.cn
[purpleendurer @ bash ~] ping -T tsandaddr g.cn
PING g.cn (114.250.66.34) 56(124) bytes of data.
^C
--- g.cn ping statistics ---
8 packets transmitted, 0 received, 100% packet loss, time 7166ms[purpleendurer @ bash ~] ping -T tsonly g.cn
PING g.cn (114.250.66.34) 56(124) bytes of data.
^C
--- g.cn ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4091ms[purpleendurer @ bash ~]
1.13 ping -v g.cn:启用详细模式ping g.cn
[purpleendurer @ bash ~] ping -v g.cn
PING g.cn (114.250.65.34) 56(84) bytes of data.
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=1 ttl=117 time=5.51 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=2 ttl=117 time=5.40 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=3 ttl=117 time=5.37 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=4 ttl=117 time=5.45 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=5 ttl=117 time=5.35 ms
64 bytes from 114.250.65.34 (114.250.65.34): icmp_seq=6 ttl=117 time=5.41 ms
^C
--- g.cn ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5006ms
rtt min/avg/max/mdev = 5.358/5.420/5.516/0.100 ms
[purpleendurer @ bash ~]
好像没有显示什么更详细的信息
3 参考资料
ping(8) - Linux man page (die.net)
相关文章:

Linux shell编程学习笔记66:ping命令 超详细的选项说明
0 前言 网络信息是电脑网络信息安全检查中的一块重要内容,Linux和基于Linux的操作系统,提供了很多的网络命令,今天我们研究最常用的ping命令。 1 ping命令 的功能、格式和选项说明 1.1 ping命令 的功能 简单来说, ping 命令 会…...

SSL/TLS和SSL VPN
1、SSL/TLS SSL安全套接字层:是一种加密协议,用于在网络通信中建立安全连接。它在应用层和传输层(TCP/IP)之间提供数据加密、服务器身份验证以及信息完整性验证 SSL只保护TCP流量,不保护UDP协议 TLS:传输层…...
浅谈WebSerice
一. 什么是WebService Web Service也称为web服务,它是一种跨编程语言和操作系统平台的远程调用技术。Web Service采用标准的SOAP协议传输(SOAP:Simple Object Access Protocol简单对象访问协议,soap属于w3c标准。并且soap协议是基…...
linux快速入门-学习笔记
linux快速入门-学习笔记 第一章:Linux系统概念及命令学习Linux系统基本概念命令终端介绍命令格式介绍Linux系统辨别目录与文件的方法通过文件详细属性辨别ls 查看目录/文件命令Linux 系统下的归属关系命令行编辑技巧Linux 基本权限的类别课后练习 第二章:…...
科普文:5种Linux下软件部署方式说明
在Linux世界里,高效、灵活地安装和管理软件是每个系统管理员和开发者的基本功。从传统的RPM包管理,到便捷的YUM软件仓库,再到颠覆性的Docker容器技术,Snap,源码安装,每一种方法都有其独到之处,适…...
Redisson中的RBlockingQueue的使用场景及例子
Redisson 的 RBlockingQueue 是一个实现了 Java BlockingQueue 接口的分布式队列,它可以用于在分布式系统中实现生产者-消费者模式。RBlockingQueue 提供了线程安全的阻塞队列操作,允许生产者在队列满时阻塞,消费者在队列空时阻塞,…...

【办公软件】Office 2019以上版本PPT 做平滑切换
Office2019以上版本可以在切页面时做平滑切换,做到一些简单的动画效果。如下在快捷菜单栏中的切换里选择平滑。 比如,在两页PPT中,使用同一个形状对象,修改了大小和颜色。 选择切换为平滑后,可以完成如下的动画显示。 …...
connect-multiparty中间件用法以及实例--文件上传中间件(保姆级别教学)
connect-multiparty中间件的用法包括安装和引入、基本设置、路由应用、文件处理以及安全和优化等步骤。 connect-multiparty是一个专为Connect和Express框架设计的文件上传中间件,它基于multiparty库,用于处理多部分表单数据,尤其针对文件上传…...

0503触发器的电路结构和工作原理
触发器的电路结构和工作原理 如何区分锁存器还是触发器, 看有没有这个三角符号,告诉是上升沿触发还是下降沿触发,没有三角符号就是电平触发。低电平触发就画个小圈。高电平触发就不画小圈。有小圈的三角就是下降沿触发 setup建立时间 hold 保…...
LeetCode:二叉树的中序遍历(C语言)
1、前序遍历:根左右 2、中序遍历:左根右 3、后序遍历:左右根 1、问题概述:二叉树中序遍历 2、示例 示例 1: 输入:root [1,null,2,3] 输出:[1,3,2] 示例 2: 输入:root […...
MySQL数据库基本安装与部署
目录 概念 数据库的基本概念 关系型数据库 非关系型数据库 MySQL 商业版与社区版 示例 初始化MySQL 添加系统服务 概念 数据库的基本概念 数据(Data) 描述事物的符号记录包括数字、文字、图形、图像、声音、档案记录等以“记录”形式按统一的…...

paraFoam 运行 报错 usr/lib/x86_64-linux-gnu/libQt5Core.so 已解决
在日常项目开发中。使用ubuntu 视图开发的时候。报错 缺少 libQt5Core 核心组件! whereis libQt5Core.so.5sudo strip --remove-section.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 完美解决,并且能正常打开,前提是,…...

科技前沿:Llama 3.1的突破与革新
在科技的长河中,每一次模型的更新都是对人类智慧的致敬。今天,我们将聚焦于Meta公司最新发布的Llama 3.1系列模型,探索其在AI领域的前沿突破。 新模型的诞生 自去年以来,Meta公司不断推进人工智能技术的发展,终于在近…...
每天一个数据分析题(四百四十七)- 业务系统
业务系统往往因为系统故障、设备故障、人为失误等原因导致数据中存在异常数据,下列哪一项方法对于发现异常值有帮助( ) A. 计算均值加减三倍标准差的范围 B. 梯度下降法 C. 相关性分析 D. 计算四分位距 数据分析认证考试介绍:…...
如何保护你的网络安全?
在2024年4月,一次创纪录的DDoS(分布式拒绝服务)攻击震惊了网络世界,这次攻击达到每秒840百万数据包(Mpps)。你可能会问,DDoS攻击到底是什么?为什么它这么重要呢? 什么是…...

Nginx 怎样处理请求的重试机制?
🍅关注博主🎗️ 带你畅游技术世界,不错过每一次成长机会! 文章目录 Nginx 怎样处理请求的重试机制?一、为何需要重试机制?二、Nginx 中的重试机制原理三、Nginx 重试机制的配置参数四、Nginx 重试机制的实际…...

自己开发软件实现网站抓取m3u8链接
几天前一个同学说想下载一个网站的视频找不到连接,问我有没有什么办法,网站抓取m3u8链接 网页抓取m3u8链接。当时一听觉得应该简单,于是说我抽空看看。然后就分析目标网页,试图从网页源码里找出连接,有的源代码直接有,但是有的没有…...
[Python3] 多模式字符串搜索 `Aho-Corasick`
ahocorasick.Automaton 是 Python 中 pyahocorasick 库提供的一个类,用于实现 Aho-Corasick 自动机。Aho-Corasick 算法是一种用于精确或近似多模式字符串搜索的高效算法。 通过 pip install pyahocorasick 安装 pyahocorasick 库。 并且,该模块是用 C 编…...
4 Types of Kaggle Competitions
1---Featured Competitions🤑🤑 These are comprehensive Machine Learning challenges posed by difficult, often business-oriented predictive problems. For example, 1⃣️Using customers history of buying insurance to predict the price t…...
【STM32】stm32中GPIO_ReadInputDataBit()是什么意思
GPIO_ReadInputDataBit()函数用于读取指定GPIO端口的某一引脚上的电平状态,并返回该引脚的电平是高电平(1)还是低电平(0)。 在STM32单片机中,GPIO(General-Purpose Input/Output)端…...
Java 语言特性(面试系列2)
一、SQL 基础 1. 复杂查询 (1)连接查询(JOIN) 内连接(INNER JOIN):返回两表匹配的记录。 SELECT e.name, d.dept_name FROM employees e INNER JOIN departments d ON e.dept_id d.dept_id; 左…...

QT: `long long` 类型转换为 `QString` 2025.6.5
在 Qt 中,将 long long 类型转换为 QString 可以通过以下两种常用方法实现: 方法 1:使用 QString::number() 直接调用 QString 的静态方法 number(),将数值转换为字符串: long long value 1234567890123456789LL; …...

JVM 内存结构 详解
内存结构 运行时数据区: Java虚拟机在运行Java程序过程中管理的内存区域。 程序计数器: 线程私有,程序控制流的指示器,分支、循环、跳转、异常处理、线程恢复等基础功能都依赖这个计数器完成。 每个线程都有一个程序计数…...

C/C++ 中附加包含目录、附加库目录与附加依赖项详解
在 C/C 编程的编译和链接过程中,附加包含目录、附加库目录和附加依赖项是三个至关重要的设置,它们相互配合,确保程序能够正确引用外部资源并顺利构建。虽然在学习过程中,这些概念容易让人混淆,但深入理解它们的作用和联…...
在树莓派上添加音频输入设备的几种方法
在树莓派上添加音频输入设备可以通过以下步骤完成,具体方法取决于设备类型(如USB麦克风、3.5mm接口麦克风或HDMI音频输入)。以下是详细指南: 1. 连接音频输入设备 USB麦克风/声卡:直接插入树莓派的USB接口。3.5mm麦克…...
Kubernetes 网络模型深度解析:Pod IP 与 Service 的负载均衡机制,Service到底是什么?
Pod IP 的本质与特性 Pod IP 的定位 纯端点地址:Pod IP 是分配给 Pod 网络命名空间的真实 IP 地址(如 10.244.1.2)无特殊名称:在 Kubernetes 中,它通常被称为 “Pod IP” 或 “容器 IP”生命周期:与 Pod …...

针对药品仓库的效期管理问题,如何利用WMS系统“破局”
案例: 某医药分销企业,主要经营各类药品的批发与零售。由于药品的特殊性,效期管理至关重要,但该企业一直面临效期问题的困扰。在未使用WMS系统之前,其药品入库、存储、出库等环节的效期管理主要依赖人工记录与检查。库…...

react菜单,动态绑定点击事件,菜单分离出去单独的js文件,Ant框架
1、菜单文件treeTop.js // 顶部菜单 import { AppstoreOutlined, SettingOutlined } from ant-design/icons; // 定义菜单项数据 const treeTop [{label: Docker管理,key: 1,icon: <AppstoreOutlined />,url:"/docker/index"},{label: 权限管理,key: 2,icon:…...
「Java基本语法」变量的使用
变量定义 变量是程序中存储数据的容器,用于保存可变的数据值。在Java中,变量必须先声明后使用,声明时需指定变量的数据类型和变量名。 语法 数据类型 变量名 [ 初始值]; 示例:声明与初始化 public class VariableDemo {publi…...
用鸿蒙HarmonyOS5实现国际象棋小游戏的过程
下面是一个基于鸿蒙OS (HarmonyOS) 的国际象棋小游戏的完整实现代码,使用Java语言和鸿蒙的Ability框架。 1. 项目结构 /src/main/java/com/example/chess/├── MainAbilitySlice.java // 主界面逻辑├── ChessView.java // 游戏视图和逻辑├── …...