while循环有什么问题?

时间:2018-06-06 00:38:20

标签: python

def clock():
    import time
    m = 0
    s = 0
    while(True):
        if((m<60) and (s<60)): print(m,":",s)
        elif(s==60):
            s == -1
            m += 1
        elif(m==60):
            print("It's been 1 hour m8")
            break
        s += 1
        time.sleep(1)

结果是,计数到0:59然后停止。它假设要到59.59。我想了解我在这里所做的fundemantal循环错误,谢谢。

1 个答案:

答案 0 :(得分:2)

s == -1

这里什么都没做。将其更改为

s = -1