直接位运算,用掩码消掉前缀: a = list(map(int,input().split('.'))) b = int(input()) print((a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3]) resb = [] resb.append(str(b>>24)) resb.append(str(b>>16 & 0xff)) resb.append(str(b>>8 & 0xff)) resb.append(str(b & 0xff)) print('.'...