I have a list structured like:
content = [
{
"a" : "b",
"c" : "d",
},
{
"e" : "f",
"g: : "h",
}
]
There are some null values in the dictionary inside there and i want to filter them in my template. That is the main purpose but for now i want to convert this lists to dictionary as im performing filter in such way:
dict((k, v) for k, v in content.items() if v is None)
And as expected it gives me an attribute error.
content
is a list. Use nested loops.
dict((k, v) for d in content for k, v in d.items() if v is None)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.