Как найти использованные и неиспользуемые IP-адреса в неотсортированном списке словарей [закрыто]Python

Программы на Python
Anonymous
Как найти использованные и неиспользуемые IP-адреса в неотсортированном списке словарей [закрыто]

Сообщение Anonymous »


This is my list:

list1 = [ {'start': '1.1.1.11', 'end': '1.1.1.20', 'cidr': '1.1.1.0/24'}, {'start': '1.1.1.22', 'end': '1.1.1.22', 'cidr': '1.1.1.0/24'}, {'start': '1.1.1.30', 'end': '1.1.1.200', 'cidr': '1.1.1.0/24'}, {'start': '3.3.3.110', 'end': '3.3.3.110', 'cidr': '3.3.3.0/24'}, {'start': '3.3.3.220', 'end': '3.3.3.250', 'cidr': '3.3.3.0/24'}, {'start': '3.3.3.56', 'end': '3.3.3.60', 'cidr': '3.3.3.0/24'}, {'start': '3.3.3.11', 'end': '3.3.3.50', 'cidr': '3.3.3.0/24'}, {'start': '4.4.4.24', 'end': '4.4.4.100', 'cidr': '4.4.4.0/24'}, {'start': '4.4.4.111', 'end': '4.4.4.111', 'cidr': '4.4.4.0/24'}, {'start': '4.4.4.11', 'end': '4.4.4.11', 'cidr': '4.4.4.0/24'}, {'start': '1.1.1.6', 'end': '1.1.1.6', 'cidr': '1.1.1.0/24'}, ] Expected output is a list of dictionaries like this:

[ {'ip': '1.1.1.1', 'status': 'free'}, {'ip': '1.1.1.2', 'status': 'free'}, ... {'ip': '1.1.1.11', 'status': 'used'}, {'ip': '1.1.1.12', 'status': 'used'}, {'ip': '1.1.1.13', 'status': 'used'}, {'ip': '1.1.1.20', 'status': 'used'}, ... {'ip': '3.3.3.1', 'status': 'free'}, ... ] I googled and I can find used/unused IPs from this question, but I don't know the things I have in mind.

Do you please help me how to have expected output?


Источник: https://stackoverflow.com/questions/781 ... ctionaries

Вернуться в «Python»