Python判断ip是否属于网段(最简洁的解决方式,没有之一)

思路:防止重复制造轮子,导入成熟的IP相关模块—IPy

import IPy

 >>>'192.168.1.100' in IPy.IP('192.168.1.0/24')
 is   True
 >>>'192.168.1.0/24' in IPy.IP('192.168.0.0/16')
 is   True
 >>>'192.168.1.0/24' in IPy.IP('192.168.0.0-192.168.8.255')
 is   True

参考:https://www.cnblogs.com/cherishry/p/5916935.html

猜你喜欢

转载自blog.csdn.net/hackerie/article/details/80598436