### ---xxx--- 表示该步骤得出的结果
IP = '192.168.96.94' list1 = IP.split('.') list2 = [] for item in list1: item = bin(int(item)) ---0b11000000 0b10101000 0b1100000 0b1011110 ----
# 去掉每段二进制前的0b. item = item[2:] # 将IP地址地址的每个字段转换成八位,不足的在每段前补0. list2.append(item.zfill(8)) --['11000000', '10101000', '01100000', '01011110']-- # 将4段8位二进制连接起来,变成32个0101的样子. v2 = ''.join(list2) ----11000000101010000110000001011110---- v3 = int(v2,base=2) print(v3) ---3232260190---