Python 循环 1 到 100:For 循环和 While 循环示例
在 Python 中,您可以使用 for 循环或 while 循环来遍历 1 到 100 的数字。
使用 for 循环:
for i in range(1, 101):
print(i)
使用 while 循环:
i = 1
while i <= 100:
print(i)
i += 1
这两种方法都能实现相同的结果,您可以根据您的偏好选择合适的循环方式。
原文地址: https://www.cveoy.top/t/topic/o2OR 著作权归作者所有。请勿转载和采集!