dd = [{}, {u'attachmentPoint': [{u'switch': u'00:0a', u'port': u'4'}], u'ipv4': [u'10.0.0.3']}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {u'attachmentPoint': [{u'switch': u'00:01', u'port': u'4'}], u'ipv4': [u'10.0.0.1']}, {u'attachmentPoint': [{u'switch': u'00:0b', u'port': u'4'}], u'ipv4': [u'10.0.0.2']}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
最后希望
dd=[ {u'Point': [{u'switch': u'00:0a', u'port': u'4'}], u'ipv4': [u'10.0.0.3']}, {u'Point': [{u'switch': u'00:01', u'port': u'4'}], u'ipv4': [u'10.0.0.1']}, {u'Point': [{u'switch': u'00:0b', u'port': u'4'}], u'ipv4': [u'10.0.0.2']}]
请问该怎么做?
dd1 = []
for x in dd:
if bool(x):
dd1.append(x)
print(dd1)
while {} in dd:
dd.remove({})