python中while 1表示什么
发布时间:2025-04-06 15:52:32
1、数字
像while 1,while 2,while -1,while -2,while x,只要x不等于0,条件总是真实的,等于while True。
while 0 等价于 while False。
相关建议:Python视频教程
2、其它变量,如字符串, 列表, 元组等
while '1',while [1, 2],while (1, 2),while x,只要len(x)>0.条件总是真实的,等同于while True。
while '',while [],while (),while x,只要len(x)=0,也就是说,条件永远不是真的,等价于 while False。
下一篇 python如何将list排序