I have a movietimes={}
It a dict I make by this code:
for i in Showtime.objects.filter(movie_id=movieid,theater_id=theaterid,datetime__range=(today,tomorrow))): if i.mvtype not in movietimes: movietimes[i.mvtype] = [] if not i.movietime > today : movietimes[i.mvtype].append(i.movietime.strftime('%Y-%m-%dT%H:%M:%S.%fZ')) if not movietimes : #this have bug for i in Showtime.objects.filter(movie_id=movieid,datetime__range=(yesterday,today)): if i.mvtype not in movietimes: movietimes[i.mvtype] = [] movietimes[i.mvtype].append(i.movietime.strftime('%Y-%m-%dT%H:%M:%S.%fZ')) return movietimes result like this:
"Times": { "ONE: [ "2014-12-24T10:40:00.000000Z", "2014-12-24T12:45:00.000000Z", "2014-12-25T14:50:00.000000Z" ] } I want to ask how can't I judge that if the [] in the 'ONE' part is null ??
I can't use if not movietimes={}: ,because there is u'ONE': [] in the dict
I have to judge the first list in the dict is empty . And there are many types u'ONE',u'TWO',u'Three'
they are catch by i.mvtype
{u'ONE': []} {u'TWO': []} {u'Three': []} Please help me ,Thank you
[]part in{u'Three': []}a guy answer my question ,I can useif not any(movietimes.values())but it's deleted