代碼演示:ui
//將獲取的IpAddr 字符串,轉換爲10進制 func IpToLong(ipAddress string) (string,uint64) { var ipSlice []string = strings.Split(ipAddress,".") var res uint64 =0 for k,v:=range ipSlice{ ip,_:=strconv.ParseUint(v,10,64) i:=uint64(k) res |= ip << ((3-i) << 3) } return ipAddress,res }