<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://blog.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://blog.liuts.com/post/198/</link>
<title><![CDATA[python IP 处理模块IPy]]></title> 
<author>刘天斯 &lt;liutiansi@gmail.com&gt;</author>
<category><![CDATA[Linux]]></category>
<pubDate>Sun, 23 May 2010 14:05:57 +0000</pubDate> 
<guid>https://blog.liuts.com/post/198/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;作为一名SA，常与IP、网络打交道，自然少不了关于IP地址的处理，现给大家推荐一个非常棒的python IP处理模块<a href="http://c0re.23.nu/c0de/IPy/" target="_blank">IPy</a>，它类似于<a href="http://search.cpan.org/dist/Net-IP/IP.pm" target="_blank">Net::IP Perl module.</a>。<a href="http://c0re.23.nu/c0de/IPy/" target="_blank">IPy</a>能够处理IPV4及IPV6的地址。<br/><br/><strong>下载地址</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/><a href="http://cheeseshop.python.org/packages/source/I/IPy/IPy-0.70.tar.gz" target="_blank">http://cheeseshop.python.org/packages/source/I/IPy/IPy-0.70.tar.gz</a><br/></div></div><br/><strong>安装</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>tar -zxvf IPy-0.42.tar.gz<br/>cd IPy-0.42<br/>python setup.py install<br/></div></div><br/><strong>简单例子</strong><br/><textarea name="code" class="python" rows="15" cols="100">
>>> import IPy
>>> IPy.IP('10.0.0.0/8').version()
4
>>> IPy.IP('::1').version()
6
>>> print IPy.IP(0x7f000001)
127.0.0.1
>>> print IPy.IP('0x7f000001')
127.0.0.1
>>> print IPy.IP('127.0.0.1')
127.0.0.1
>>> print IPy.IP('10')
10.0.0.0

>>> print IPy.IP('1080:0:0:0:8:800:200C:417A')
1080:0000:0000:0000:0008:0800:200c:417a
>>> print IPy.IP('1080::8:800:200C:417A')
1080:0000:0000:0000:0008:0800:200c:417a
>>> print IPy.IP('::1')
0000:0000:0000:0000:0000:0000:0000:0001
>>> print IPy.IP('::13.1.68.3')
0000:0000:0000:0000:0000:0000:0d01:4403

>>> print IPy.IP('127.0.0.0/8')
127.0.0.0/8
>>> print IPy.IP('127.0.0.0/255.0.0.0')
127.0.0.0/8
>>> print IPy.IP('127.0.0.0-127.255.255.255')
127.0.0.0/8

>>> IPy.IP('10.0.0.0/24').strNormal(q)
'10.0.0.0/24'
>>> IPy.IP('10.0.0.0/24').strNormal(2)
'10.0.0.0/255.255.255.0'
>>> IPy.IP('10.0.0.0/24').strNormal(3)
'10.0.0.0-10.0.0.255'
</textarea><br/>Tags - <a href="https://blog.liuts.com/tags/python/" rel="tag">python</a> , <a href="https://blog.liuts.com/tags/ipy/" rel="tag">ipy</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/198/#blogcomment81</link>
<title><![CDATA[[评论] python IP 处理模块IPy]]></title> 
<author>menghan &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 25 May 2010 06:39:40 +0000</pubDate> 
<guid>https://blog.liuts.com/post/198/#blogcomment81</guid> 
<description>
<![CDATA[ 
	何不使用ipaddr-py？Google出品，质量有保证
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/198/#blogcomment2522</link>
<title><![CDATA[[评论] python IP 处理模块IPy]]></title> 
<author>champion &lt;xiejieling@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 20 Dec 2014 08:19:47 +0000</pubDate> 
<guid>https://blog.liuts.com/post/198/#blogcomment2522</guid> 
<description>
<![CDATA[ 
	IPy 貌似只能支持24位，对于10.0.1.0/22&nbsp;&nbsp;ValueError: IP(&#039;1.0.1.0/22&#039;) has invalid prefix length (22)
]]>
</description>
</item>
</channel>
</rss>