2008年01月06日 星期日 10:35
一个HTML附件被移除... URL: http://python.cn/pipermail/python-chinese/attachments/20080106/8a484624/attachment.html
2008年01月06日 星期日 14:51
a=1
b=1
for a in range(a,255):
for b in range(b,255):
print str(a)+"."+ str(b)
...后面2个段自己加上就行了
在 08-1-6,fluke.l<fluke.l在gmail.com> 写道:
> 多少个段就多少重循环来从右边生成,跳过一些保留地址就好了,毕竟是递增的。
>
> 另外一种办法是写成二进制,增加主机位,满了再加网络号。再一边换成点分十进制表示。
>
> -----------------------
> 欢迎使用手机浏览器UCWEB
>
> ---原邮件---
> 发件人:searun
> 发送时间:2008-01-06 10:13
> 收件人:python-chinese
> 主题:[python-chinese] 请问怎么快速的生成IP列表
>
> 现在给定一个字符串: x.x.x.x - x.x.x.x,怎么快速的生成在这两个IP域之间的所有IP?
> 比如 1.1.1.2 - 1.1.1.5 生成
> ('1.1.1.2','1.1.1.3','1.1.1.4','1.1.1.5')
>
> 我现在的做法是一个一个比较过来,代码写得非常臃肿。
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
2008年01月07日 星期一 00:07
IP就是32位整数啊,
a='172.31.0.1'
b='172.31.2.255'
def ip2str(ip):
return
'.'.join([str(ip/16777216),str(ip%16777216/65536),str(ip%65536/256),str(ip%256)])
ip=a.split('.')
ipa=int(ip[0])*256*256*256+int(ip[1])*65536+int(ip[2])*256+int(ip[3])
ip=b.split('.')
ipa=int(ip[0])*256*256*256+int(ip[1])*65536+int(ip[2])*256+int(ip[3])
for i in range(ipa, ipb+1):
print(ip2str(i))
On Jan 6, 2008 2:51 PM, 篱笆 <nameliba在gmail.com> wrote:
> a=1
> b=1
> for a in range(a,255):
> for b in range(b,255):
> print str(a)+"."+ str(b)
> ...后面2个段自己加上就行了
>
> 在 08-1-6,fluke.l<fluke.l在gmail.com> 写道:
> > 多少个段就多少重循环来从右边生成,跳过一些保留地址就好了,毕竟是递增的。
> >
> > 另外一种办法是写成二进制,增加主机位,满了再加网络号。再一边换成点分十进制表示。
> >
> > -----------------------
> > 欢迎使用手机浏览器UCWEB
> >
> > ---原邮件---
> > 发件人:searun
> > 发送时间:2008-01-06 10:13
> > 收件人:python-chinese
> > 主题:[python-chinese] 请问怎么快速的生成IP列表
> >
> > 现在给定一个字符串: x.x.x.x - x.x.x.x,怎么快速的生成在这两个IP域之间的所有IP?
> > 比如 1.1.1.2 - 1.1.1.5 生成
> > ('1.1.1.2','1.1.1.3','1.1.1.4','1.1.1.5')
> >
> > 我现在的做法是一个一个比较过来,代码写得非常臃肿。
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20080107/8289327e/attachment.htm
2008年01月07日 星期一 10:44
赞~ On Jan 7, 2008 12:07 AM, Shao Feng <sevenever at gmail.com> wrote: > IP就是32位整数啊, > > a='172.31.0.1' > b='172.31.2.255' > > def ip2str(ip): > return > '.'.join([str(ip/16777216),str(ip%16777216/65536),str(ip%65536/256),str(ip%256)]) > > ip=a.split('.') > ipa=int(ip[0])*256*256*256+int(ip[1])*256*256+int(ip[2])*256+int(ip[3]) > ip=b.split('.') > ipb=int(ip[0])*256*256*256+int(ip[1])*256*256+int(ip[2])*256+int(ip[3]) > > for i in range(ipa, ipb+1): > print(ip2str(i)) >
2008年01月07日 星期一 14:40
"IP¾ÍÊÇ32λÕûÊý°¡"£¬Ò»ÓïµÀÆÆ±¾ÖÊ£¬ÔÞ£¡ ÔÚ08-1-7£¬Shao Feng <sevenever在gmail.com> дµÀ£º > > IP¾ÍÊÇ32λÕûÊý°¡£¬ > a='172.31.0.1' > b='172.31.2.255' > > def ip2str(ip): > return > '.'.join([str(ip/16777216),str(ip%16777216/65536),str(ip%65536/256),str(ip%256)]) > > > ip=a.split('.') > ipa=int(ip[0])*256*256*256+int(ip[1])*65536+int(ip[2])*256+int(ip[3]) > ip=b.split('.') > ipa=int(ip[0])*256*256*256+int(ip[1])*65536+int(ip[2])*256+int(ip[3]) > > for i in range(ipa, ipb+1): > print(ip2str(i)) > > On Jan 6, 2008 2:51 PM, Àé°Ê < nameliba在gmail.com> wrote: > > > a=1 > > b=1 > > for a in range(a,255): > > for b in range(b,255): > > print str(a)+"."+ str(b) > > ...ºóÃæ2¸ö¶Î×Ô¼º¼ÓÉϾÍÐÐÁË > > > > ÔÚ 08-1-6£¬fluke.l<fluke.l在gmail.com> дµÀ£º > > > ¶àÉÙ¸ö¶Î¾Í¶àÉÙÖØÑ»·À´´ÓÓÒ±ßÉú³É£¬Ìø¹ýһЩ±£ÁôµØÖ·¾ÍºÃÁË£¬±Ï¾¹ÊǵÝÔöµÄ¡£ > > > > > > ÁíÍâÒ»ÖÖ°ì·¨ÊÇд³É¶þ½øÖÆ£¬Ôö¼ÓÖ÷»ú룬ÂúÁËÔÙ¼ÓÍøÂçºÅ¡£ÔÙÒ»±ß»»³Éµã·ÖÊ®½øÖƱíʾ¡£ > > > > > > ----------------------- > > > »¶ÓʹÓÃÊÖ»úä¯ÀÀÆ÷UCWEB > > > > > > ---ÔÓʼþ--- > > > ·¢¼þÈË:searun > > > ·¢ËÍʱ¼ä:2008-01-06 10:13 > > > ÊÕ¼þÈË:python-chinese > > > Ö÷Ìâ:[python-chinese] ÇëÎÊÔõô¿ìËÙµÄÉú³ÉIPÁбí > > > > > > ÏÖÔÚ¸ø¶¨Ò»¸ö×Ö·û´®: x.x.x.x - x.x.x.x£¬Ôõô¿ìËÙµÄÉú³ÉÔÚÕâÁ½¸öIPÓòÖ®¼äµÄËùÓÐIP£¿ > > > ±ÈÈç 1.1.1.2 - 1.1.1.5 Éú³É > > > ('1.1.1.2','1.1.1.3','1.1.1.4',' 1.1.1.5') > > > > > > ÎÒÏÖÔÚµÄ×ö·¨ÊÇÒ»¸öÒ»¸ö±È½Ï¹ýÀ´£¬´úÂëдµÃ·Ç³£Ó·Öס£ > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20080107/ba049f59/attachment-0001.html
2008年01月07日 星期一 16:52
IPv6ÄØ?? ÔÚ08-1-7£¬Li Qingfeng <liqfemail在gmail.com> дµÀ£º > > "IP¾ÍÊÇ32λÕûÊý°¡"£¬Ò»ÓïµÀÆÆ±¾ÖÊ£¬ÔÞ£¡ > > ÔÚ08-1-7£¬Shao Feng <sevenever在gmail.com> дµÀ£º > > > > IP¾ÍÊÇ32λÕûÊý°¡£¬ > > a='172.31.0.1' > > b=' 172.31.2.255' > > > > def ip2str(ip): > > return > > '.'.join([str(ip/16777216),str(ip%16777216/65536),str(ip%65536/256),str(ip%256)]) > > > > > > ip=a.split('.') > > ipa=int(ip[0])*256*256*256+int(ip[1])*65536+int(ip[2])*256+int(ip[3]) > > ip=b.split('.') > > ipa=int(ip[0])*256*256*256+int(ip[1])*65536+int(ip[2])*256+int(ip[3]) > > > > for i in range(ipa, ipb+1): > > print(ip2str(i)) > > > > On Jan 6, 2008 2:51 PM, Àé°Ê < nameliba在gmail.com> wrote: > > > > > a=1 > > > b=1 > > > for a in range(a,255): > > > for b in range(b,255): > > > print str(a)+"."+ str(b) > > > ...ºóÃæ2¸ö¶Î×Ô¼º¼ÓÉϾÍÐÐÁË > > > > > > ÔÚ 08-1-6£¬fluke.l<fluke.l在gmail.com > дµÀ£º > > > > ¶àÉÙ¸ö¶Î¾Í¶àÉÙÖØÑ»·À´´ÓÓÒ±ßÉú³É£¬Ìø¹ýһЩ±£ÁôµØÖ·¾ÍºÃÁË£¬±Ï¾¹ÊǵÝÔöµÄ¡£ > > > > > > > > ÁíÍâÒ»ÖÖ°ì·¨ÊÇд³É¶þ½øÖÆ£¬Ôö¼ÓÖ÷»ú룬ÂúÁËÔÙ¼ÓÍøÂçºÅ¡£ÔÙÒ»±ß»»³Éµã·ÖÊ®½øÖƱíʾ¡£ > > > > > > > > ----------------------- > > > > »¶ÓʹÓÃÊÖ»úä¯ÀÀÆ÷UCWEB > > > > > > > > ---ÔÓʼþ--- > > > > ·¢¼þÈË:searun > > > > ·¢ËÍʱ¼ä:2008-01-06 10:13 > > > > ÊÕ¼þÈË:python-chinese > > > > Ö÷Ìâ:[python-chinese] ÇëÎÊÔõô¿ìËÙµÄÉú³ÉIPÁбí > > > > > > > > ÏÖÔÚ¸ø¶¨Ò»¸ö×Ö·û´®: x.x.x.x - x.x.x.x£¬Ôõô¿ìËÙµÄÉú³ÉÔÚÕâÁ½¸öIPÓòÖ®¼äµÄËùÓÐIP£¿ > > > > ±ÈÈç 1.1.1.2 - 1.1.1.5 Éú³É > > > > ('1.1.1.2',' 1.1.1.3','1.1.1.4',' 1.1.1.5') > > > > > > > > ÎÒÏÖÔÚµÄ×ö·¨ÊÇÒ»¸öÒ»¸ö±È½Ï¹ýÀ´£¬´úÂëдµÃ·Ç³£Ó·Öס£ > > > > _______________________________________________ > > > > python-chinese > > > > Post: send python-chinese在lists.python.cn > > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20080107/fb8e4933/attachment.html
2008年01月11日 星期五 09:19
´Õ¸öÈÈÄÖ
a='172.31.0.1'
b='172.31.2.255'
def ip2str(ip):
ret=[]
for i in range(4):
ret.insert(0,str(ip%256))
ip=int(ip/256)
return '.'.join(ret)
def str2ip(sip):
ret=0
ip=sip.split('.')
for i in range(4):
ret=ret*256+int(ip.pop(0))
return ret
for i in range(str2ip(a),str2ip(b)+1):
print ip2str(i)
On Mon, 7 Jan 2008 00:07:06 +0800
"Shao Feng" <sevenever在gmail.com> wrote:
> IPA¥32Ê®?C
> a='172.31.0.1'
> b='172.31.2.255'
>
> def ip2str(ip):
> return
> '.'.join([str(ip/16777216),str(ip%16777216/65536),str(ip%65536/256),str(ip%256)])
>
> ip=a.split('.')
> ipa=int(ip[0])*256*256*256+int(ip[1])*65536+int(ip[2])*256+int(ip[3])
> ip=b.split('.')
> ipa=int(ip[0])*256*256*256+int(ip[1])*65536+int(ip[2])*256+int(ip[3])
>
> for i in range(ipa, ipb+1):
> print(ip2str(i))
>
> On Jan 6, 2008 2:51 PM, ?â <nameliba在gmail.com> wrote:
>
> > a=1
> > b=1
> > for a in range(a,255):
> > for b in range(b,255):
> > print str(a)+"."+ str(b)
> > ...@Ê2¢i©ÈÁãAs¹
> >
> > Ý 08-1-6Cfluke.l<fluke.l在gmail.com> ʹF
> > > ½¢iA½dz?¸E?¶¬Cµ?ê±Û¯n¬AD¹C?èí¥?úIB
> > >
> > > ?Oê??@¥Ê¬ñ?§CúÁå÷ÊC?¹ÄÁã¤?BÄê??¬_ª\?§\¦B
> > >
> > > -----------------------
> > > ?}gpè÷??íUCWEB
> > >
> > > ---´?---
> > > ?l:searun
> > > ???:2008-01-06 10:13
> > > ¾l:python-chinese
> > > å?:[python-chinese] ???õ¬I¶¬IPñ\
> > >
> > > ?Ý?èê¢ø: x.x.x.x - x.x.x.xC?õ¬I¶¬Ý??¢IPæV?ILIPH
> > > ä@ 1.1.1.2 - 1.1.1.5 ¶¬
> > > ('1.1.1.2','1.1.1.3','1.1.1.4','1.1.1.5')
> > >
> > > ä?ÝIô@¥ê¢ê¢ä??Cã?ʾñí??B
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
--
ww <wang.wei在software.eteda.com>
Zeuux © 2025
京ICP备05028076号