ip校验 对ip格式的校验,对于特殊的ip类型,需要单独再做判断筛选: 方法一: import ipaddress ip = "0.0.0.0" try: result = ipaddress.ip_address(ip) except Exception as e: print("the ip is illegal") else: print("the ip is legal") 方法二: import IPy ip = "1.1.1.1" try: result = IPy.IP