Skip to main content
 首页 » 编程设计

python之while 循环 (Python)

2025年05月04日17cmt

如果我想在 while 循环中说一些东西,比如:while time is greater than or equal to 0,它会简单地写成 while time > 还是 == 0?或者没有办法做到这一点?

请您参考如下方法:

使用while time >= 0(等同于while time > 0 or time == 0)

>>> 0 >= 0 
True 
>>> 1 >= 0 
True 
>>> -1 >= 0 
False