python每十个数换行

2026-02-14 01:02:39

1、新建文件

python编辑器中,点击“File—New File”,新建文件

python每十个数换行

2、输入代码

for i in range(1,101): 

    print("%3d" % i, end=" ")  #不换行输出

    if(i % 10 == 0): 

        print( "\n")  #换行输出

python每十个数换行

3、运行代码

按f5键或者点击“Run—Run Module”运行代码

python每十个数换行

4、运行结果

在运行结果中就能看到每一行输出10个数字了

python每十个数换行

相关推荐
  • 阅读量:171
  • 阅读量:48
  • 阅读量:37
  • 阅读量:162
  • 阅读量:85
  • 猜你喜欢