问题描述: Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) 算法分析: 首先我们…
def isIp(ip_str): flag = True if '.' not in ip_str: return False if ip_str.count('.')!=3 : return False splitList = ip_str.split('.') for value in splitList: try: num = int(value) if num>=0 and num<=255: pass else: flag = False except: flag = False…