将IP地址字符串转为32位二进制
def str2bin(s): temp = s.split('.') result = '' for i in range(len(temp)): temp[i] = str(bin(int(temp[i]))[2:]) if len(temp[i]) < 8: temp[i] = '0'*(8-len(temp[i])) + tenp[i] result += str(temp[i]) return result
def str2bin(s): temp = s.split('.') result = '' for i in range(len(temp)): temp[i] = str(bin(int(temp[i]))[2:]) if len(temp[i]) < 8: temp[i] = '0'*(8-len(temp[i])) + tenp[i] result += str(temp[i]) return result