如何在 Python 中获取给定前缀长度的主机掩码/网络掩码
为了获取例如 /112 IPv6 前缀的主机掩码,使用:
ipv6-netmask-hostmask.py
import ipaddress
# 获取 /112 前缀的网络掩码
ipaddress.IPv6Network("::/112").netmask
# 获取 /112 前缀的主机掩码
ipaddress.IPv6Network("::/112").hostmaskCheck out similar posts by category:
Networking, Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow