题解 | #整数与IP地址间的转换#
整数与IP地址间的转换
https://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea
用format补全0的位数即可
while True: try: s1=input().split('.') s2=format(bin(int(input()))[2:],'0>32') l='' for a in s1: l+=format(bin(int(a))[2:],'0>8') print(int(l,2)) s=[] for i in range(0,32,8): s.append(str(int(s2[i:i+8],2))) print('.'.join(s)) except: break