本文摘自php中文网,作者silencement,侵删。

打印1~20之间整数的方法:
1、使用for循环
1 2 | for i in range(1,21):
print(i,end=',')
|
输出结果
1 | 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
|
2、使用while循环
1 2 3 4 | i= 1
while i <= 20:
print(i,end=',')
i += 1
|
输出结果
1 | 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
|
以上就是python如何打印1~20的整数的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
用 Python 连接 mysql 的几种方式详解_Python
Python自学要多久能学会
scrapy安装教程 pip 或 conda 两种安装方法.
如何用Python开发网页
有关Python的md5加密用法详解
Python画图的两种方法
Python get函数有什么作用?示例解析
利用Python微信库itchat实现微信自动回复功能
Python爬虫难吗
Python爬虫怎么挣钱
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python如何打印1~20的整数