【发布时间】:2021-02-19 04:26:47
【问题描述】:
编写一个脚本,打印 1 到 100 之间的每个偶数,每行一个
nums=list(range(1,100))
for i in nums:
if i%2 ==0:
print(i)
结果:Python 的范围是半开的(包括开始,不包括停止)。 为什么以及如何
【问题讨论】:
-
这能回答你的问题吗? Why does range(start, end) not include end?
标签: python python-3.x python-2.7