Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. from netaddr import IPAddress, IPNetwork
  2.  
  3. with open("your file.txt", "r") as f:
  4. for line in f:
  5. if "/" in line:
  6. ip_network = IPNetwork(line)
  7. print "{},{}".format(
  8. ip_network.first,
  9. ip_network.last
  10. )
  11. if "," in line:
  12. first_ip, last_ip = line.split(",")
  13. else:
  14. first_ip = last_ip = line
  15. print "{},{}".format(
  16. int(IPAddress(first_ip)),
  17. int(IPAddress(last_ip))
  18. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement