
打印1~20之间整数的方法:
1、使用for循环
for i in range(1,21):
print(i,end=',')输出结果
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
2、使用while循环
立即学习“Python免费学习笔记(深入)”;
i= 1
while i <= 20:
print(i,end=',')
i += 1输出结果
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
以上就是python如何打印1~20的整数的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号