今天鹅厂店面,最后问了一个ip地址字符串和整数间无损转化的问题,晚上有时间了手撸了一下代码. public class IPstr { public static void main(String args[]){ ipstrToint sti=new ipstrToint(); int ip=0; ip=sti.strToint("127.11.22.33"); if(ip==0) System.out.println("无效IP"); else System.o…
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…
Given a start IP address ip and a number of ips we need to cover n, return a representation of the range as a list (of smallest possible length) of CIDR blocks. A CIDR block is a string consisting of an IP, followed by a slash, and then the prefix le…
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Text.RegularExpressions; namespace AIMSCommon { /// <summary> /// 根据IP地址查询所在地 /// </summary> public class IPScanerHelper { #region 私有成员 private st…
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net.NetworkInformation; using System.Threading; namespace Manager.Common { public static class NetCommon{ /// <summary> /// 验证IP地址字符串的正确性 /// </summa…