根据ip地址和子网掩码计算网段地址和广播地址(原创)
Python里有一个专门处理该类问题的IP类库,来看看:
#! /usr/bin/env python import sys from IPy import IP address = sys.argv[1] netmask = sys.argv[2] #print address,netmask #help(IP) networkAddress = IP(address).make_net(netmask) # init a IP instance, can with netmask directly, or use make_net(netmask) bcastAddress = IP(networkAddress).broadcast() # return the broadcast ip address print networkAddress print bcastAddress
版权声明:本文为maodouzi原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。