from IPy import IP
def ipnetwork(ip, mask):
return IP(ip).make_net(mask)
def issamenetwork(ip1, mask1, ip2, mask2):
return ipnetwork(ip1, mask1) == ipnetwork(ip2, mask2)
con=sqlite3.connect(":memory:")
con.create_function("IPAddCheck",4,issamenetwork)
cur=con.cursor()
cur.execute("""
select *
from table1
join table2 on 1=1
and IPAddCheck(table1.ip,table1.mask, table2.ip, table2.mask)
""")
python 应用 IPy 计算IP/掩码的网络地址
最新推荐文章于 2023-08-22 14:59:48 发布