11 lines
232 B
Python
11 lines
232 B
Python
import ipaddress
|
|
|
|
ip = ipaddress.IPv4Address('172.16.0.0')
|
|
bits = '{:#b}'.format(ip).strip('0b')
|
|
|
|
result = ''
|
|
for i in range(0, 32, 4):
|
|
result += bits[i:i+4]
|
|
result += ' ' if (i + 4) % 8 == 0 else ' '
|
|
|
|
print(result.strip()) |