'ValueError: not enough values to unpack (expected 2, got 1) in proxy
i am creating a function to loop through a list of IPs but i'm getting the ValueError: not enough values to unpack (expected 2, got 1)
def cidr_to_ips():
for i in range(len(blocked_cidr)):
(ip, cidr) = blocked_cidr[i].split('/')
cidr = int(cidr)
host_bits = 32 - cidr
i = struct.unpack('>I', socket.inet_aton(ip))[0]
start = (i >> host_bits) << host_bits
end = start | ((1 << host_bits))
end += 1
for i in range(start, end):
tp_ip = socket.inet_ntoa(struct.pack('>I', i))
blocked_ips.append(tp_ip)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|