题解 | #整数与IP地址间的转换#
整数与IP地址间的转换
https://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea
s1 = input().split(".") s2 = input() s3 = "" arr1 = [] s4 = bin(int(s2)).replace("0b", "").rjust(32, "0") for i in s1: temp = bin(int(i)) s3 += temp.replace("0b", "").rjust(8, "0") for j in range(0, len(s4), 8): val = int(s4[j : j + 8], 2) arr1.append(str(val)) print(int(s3, 2)) print(".".join(arr1))