Passing a Variable to IPV4Network or ip_network

121 Views Asked by At

Can someone advise how i can pass a variable from a test file to the ipaddress module, i've tried a couple of different variations:

with open('VLANs.txt', 'r') as vlan_file:
for line in vlan_file:
    data = line.split(sep='\t')
    ip_address = ip.IPv4Network(data[4].strip())
    print(ip_address)

with open('VLANs.txt', 'r') as vlan_file:
for line in vlan_file:
    data = line.split(sep='\t')
    ip_address = ip.ip_network(data[4].strip())
    print(ip_address)

I get an address value error - i've tried casting to a string which is the usual type and to an IP address, none of which works.

0

There are 0 best solutions below