直接上代码 def check_ip_type(ip_ym_str): """ :param ip_ym_str: 1.1.1.1255.255.255.0 :return: A B C D E R P """ ip_str, ym_str = ip_ym_str.split('') # 先判断子网掩码 if ym_str.count('.') != 3 or '..' in ym_str: return 'R' a, b, c, d = list(map(int, ym_str.split('.'))) all_ym_str = '...