def validate_ip_network(network, strict=True):
'''
If network is a valid IP network when parsed according to strict,
return it as an ipnetwork object.
Otherwise, return None.
'''
try:
return ipaddress.ip_network(unicode(address), strict=strict)
except ValueError:
return None
评论列表
文章目录