The following exception was encountered while working with CIDR:
A = IPAddress. Ipv4network (' 10.75.74.188/24 ')
Traceback (most recent call last):
File "<input>", line 1, in <module >
File "C:\Users\exihaxi\AppData\Local\Programs\Python\Python36-32\lib\ipaddress.py", line 1536, in __init__
raise ValueError ('%s has host bits set '% self)
VALUEERROR:10.75.74.188/24 has host bits set
There is no denying the fact that the address is not reasonable. But after the code has spelled out the address, the main purpose is to take the netmask, so it doesn't care about the IP part at all.
By studying the document, we can see the following description:
If Strict is True and host bits are set in the supplied address, then ValueError is raised.
Otherwise, the host bits are masked out to determine the appropriate address.
So you can take the following solutions:
A = IPAddress. Ipv4network (' 10.75.74.188/24 ', False)
str (a.netmask)