本文整理汇总了Python中Function.get_network方法的典型用法代码示例。如果您正苦于以下问题:Python Function.get_network方法的具体用法?Python Function.get_network怎么用?Python Function.get_network使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Function
的用法示例。
在下文中一共展示了Function.get_network方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: import Function [as 别名]
# 或者: from Function import get_network [as 别名]
host_id = []
for i in range(0, int(num_subnet)):
host_id.append(int(32 - math.log(int(subnet[i]), 2)))
print(host_id)
'''
ip_block = []
for i in range(0, int(num_subnet)):
ip_block.append(ip_address + "/" + str(host_id[i]))
print(ip_block)
'''
#network 0
ip_block = ip_address + "/" + str(host_id[0])
print("Network 0: ")
print("- Network address: " + str(f.get_network(ip_block)) + "/" + str(host_id[0]))
print("- Broadcast: " + str(f.get_broadcast(ip_block)))
print("- Subnet mask: " + str(f.get_mask(ip_block)))
first_host, last_host = f.get_range(ip_block)
print("- Range host: " + str(first_host) + " -> " + str(last_host))
print()
ip_address = f.get_broadcast(ip_block) + 1
for i in range(1, int(num_subnet)):
ip_block = str(ip_address) + "/" + str(host_id[i])
print("Network " + str(i) + ": ")
print("- Network address: " + str(f.get_network(ip_block)) + "/" + str(host_id[i]))
print("- Broadcast: " + str(f.get_broadcast(ip_block)))
print("- Subnet mask: " + str(f.get_mask(ip_block)))
first_host, last_host = f.get_range(ip_block)