我想做一个项目使用嵌套if。但它不起作用。为什么? 我的代码,嵌套,如果不在django工作
schedule = Schedule.objects.all()
for c in schedule :
p = c.poll
e = c.end_time
s = c.start_time
n = c.no_of_response
now = timezone.now()
#phn = Response.objects.filter(poll = p).exclude(sid = 'Null').count()
if (c.start_time <= now) & (now <= c.end_time):
if n == 0:
c.poll.status='Running'
c.poll.save()
是什么不工作?请提供更多信息。 – ilse2005
你没有包含什么'no_of_response'的信息,(我会留下我的答案,因为我仍然认为这是一个错误) – Sayse
if(c.start_time <= now)&(now <= c.end_time ): \t \t \t c.poll.status = '正在运行' \t \t \t c.poll.save()此代码工作。但是,当我把嵌套if,即如果n == 0:,在第一个if条件内,那么整个代码不起作用。为什么会发生? – naveen