擅长:python、mysql、java
<p>您可以尝试以下代码:</p>
<pre><code>def from_string(s):
"Convert dotted IPv4 address to integer."
return reduce(lambda a,b: a<<8 | b, map(int, s.split(".")))
def to_string(ip):
"Convert 32-bit integer to dotted IPv4 address."
return ".".join(map(lambda n: str(ip>>n & 0xFF), [24,16,8,0]))
ip = '90.1.0.0'
count = 12000
block_size = 1024
ip_int = from_string(ip)
while count > 0:
delta = min(count, block_size)
print to_string(ip_int), delta
ip_int += delta
count -= delta
</code></pre>
<p>IP转换代码取自<a href="https://gist.github.com/cslarsen/1595135" rel="nofollow">here</a>。在</p>