文章内容
2021/4/6 9:29:40,作 者: 黄兵
Python判断IP是否是私有地址
在Python中如何判断一个IP地址是否是私有IP地址?具体代码如下:
import ipaddress ipaddress.ip_address('192.168.0.1').is_private # output True
从Python 3.3开始,ipaddress模块才可以使用,具体文档可以参考这里:ipaddress
参考资料:
1、How do you determine if an IP address is private, in Python?
UnicodeDecodeError:'gbk' codec can't decode byte 0x93 in position 0 illegal multibyte sequence
Python CIDR计算IP数量
Python CIDR计算IP数量
评论列表