题解 | 整数与IP地址间的转换
整数与IP地址间的转换
https://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea
ip = input().split('.') ip_int = int(input()) ip_bin = [] for i in ip: ip_bin.append(f'{int(i):08b}') print(int(''.join(ip_bin),2)) a = f'{ip_int:032b}' int_bin = [] for i in range(0,len(a),8): int_bin.append(str(int(a[i:i+8],2))) print('.'.join(int_bin))