sunmsn's recent timeline updates
sunmsn

sunmsn

V2EX member #179741, joined on 2016-06-30 16:57:13 +08:00
sunmsn's recent replies
Jul 19, 2016
Replied to a topic by fsckzy 程序员 shell 能实现这样的功能吗?还是要 python?
import netaddr

def ip2int(addr):
return int(netaddr.IPAddress(addr))

def int2ip(addr):
return str(netaddr.IPAddress(addr))

with open('data.txt','r') as f:
for line in f:
ip_1,ip_2 = line.strip().split()
for i in range(ip2int(ip_1),ip2int(ip_2)+1):
print int2ip(i)
print '-'*80
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2737 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 15:39 · PVG 23:39 · LAX 08:39 · JFK 11:39
♥ Do have faith in what you're doing.