8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d9e3412 commit 839b3efCopy full SHA for 839b3ef
experiments/ip.py
@@ -0,0 +1,26 @@
1
+import ipaddress
2
+
3
4
+def main():
5
+ my_ip = '216.58.194.206'
6
7
+ print(my_ip)
8
9
+ addr = ipaddress.ip_address(my_ip)
10
11
+ print(ipaddress.ip_network(my_ip))
12
+ print('Compressed: ', addr.compressed)
13
+ print('Exploded: ', addr.exploded)
14
+ print('Packed: ', addr.packed)
15
+ print('As int: ', int(addr))
16
+ print('As binary: ', bin(int(addr)))
17
18
+ print('-------------------')
19
20
+ network_mask = '192.0.2.0/24'
21
+ print('Network mask: ', network_mask)
22
+ print('Network subnets: ', list(ipaddress.ip_network(network_mask).subnets()))
23
24
25
+if __name__ == '__main__':
26
+ main()
0 commit comments