好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python如何打印1~20的整数

打印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循环

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的整数的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于python如何打印1~20的整数的详细内容...

  阅读:65次