def clean_empty(d):
"""
清除字典中值为空的键值对
"""
if not isinstance(d, (dict, list)):
return d
if isinstance(d, list):
return [v for v in (clean_empty(v) for v in d) if (v or v == 0)]
value = {k: v for k, v in ((k, clean_empty(v)) for k, v in d.items()) if (v or v == 0)}
return value