python求ipv4广播地址
下面展示 实现代码,可以直接运行。
ipv4_addr
= "192.168.1.1"
ipv4_netmask
= "255.255.255.0"
ip
= ipv4_addr
.split
('.')
netmask
= ipv4_netmask
.split
('.')
ip
= [int(bin(int(octet
)),2) for octet
in ip
]
netmask
= [int(bin(int(octet
)),2) for octet
in netmask
]
broadcast
= [(ioctet
| (moctet
^0xff)) for ioctet
, moctet
in zip(ip
, netmask
)]
转载请注明原文地址: https://lol.8miu.com/read-20104.html