classSolution(object): defcompareVersion(self, version1, version2): """ :type version1: str :type version2: str :rtype: int """ v1 = [int(i) for i in version1.split('.')] v2 = [int(i) for i in version2.split('.')] if len(v1)>len(v2): for i in range(len(v2)): if v1[i] > v2[i]: return1 elif v1[i] < v2[i]: return-1 if max(v1[len(v2):]) > 0:return1 else:return0 elif len(v1) < len(v2): for i in range(len(v1)): if v1[i] > v2[i]: return1 elif v1[i] < v2[i]: return-1 if max(v2[len(v1):]) > 0:return-1 else:return0 else: for i in range(len(v1)): if v1[i] > v2[i]: return1 elif v1[i] < v2[i]: return-1 return0