Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from netaddr import IPAddress, IPNetwork
- with open("your file.txt", "r") as f:
- for line in f:
- if "/" in line:
- ip_network = IPNetwork(line)
- print "{},{}".format(
- ip_network.first,
- ip_network.last
- )
- if "," in line:
- first_ip, last_ip = line.split(",")
- else:
- first_ip = last_ip = line
- print "{},{}".format(
- int(IPAddress(first_ip)),
- int(IPAddress(last_ip))
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement