Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. ["[IPv4Address('192.168.1.254')]"]
  2. Traceback (most recent call last):
  3. File "./test.py", line 27, in <module>
  4. print(dir(a[:]))
  5. TypeError: 'NoneType'
  6.  
  7. python3
  8. import ipaddress
  9. import csv
  10.  
  11. used_ips = []
  12.  
  13. def csv_dict_reader(file_obj):
  14. """
  15. Read a CSV file using csv.DictReader
  16. """
  17. reader = csv.DictReader(file_obj, delimiter=',')
  18. for line in reader:
  19. used_ips.append(line["ip_address"])
  20. print(used_ips)
  21.  
  22. def ip_list(network_addr):
  23. ips = []
  24. addr = ipaddress.ip_network(network_addr)
  25. for i in addr.hosts():
  26. ips.append([i])
  27.  
  28. if __name__ == "__main__":
  29. with open("data.csv") as f_obj:
  30. csv_dict_reader(f_obj)
  31.  
  32. a = ip_list('192.168.1.0/24')
  33. print(dir(a[:]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement