在Django IF ELSE中无法在For循环中使用

时间:2019-07-03 09:18:23

标签: python python-2.7

for product in products:
    for dess in peice:
        for cell in sell:
            try:
                if product == dess:
                    print(123)
                else:
                    if product == sell:
                        print(456)
                    else:
                        print(nothing)
            except:
                pass
  

我尝试使用if来运行这种for循环。但是如果第一个陈述   然后从循环中退出,不显示任何结果。你能检查一下是什么吗   问题?

1 个答案:

答案 0 :(得分:0)

for product in products:
    for dess in peice:
    for cell in sell:
            try:
                if product == dess:
                    print(123)
                break
                if product == sell:
                   print(456)
                else:
                    print(nothing)
            except:
                pass