当前位置:主页 > 软件编程 > Python代码 >

python把数组中的数字每行打印3个并保存在文档中的方法

时间:2021-07-22 07:46:55 | 栏目:Python代码 | 点击:

如下所示:

arrs=[2,15,48,4,5,6,7,6,4,1,2,3,6,6,7,4,6,8]
f=open('test.txt','w+')
count=0
for temp in arrs:
 count+=1
 print >> f,temp,
 if(count%3==0):
  print >> f
f.close()

结果:

您可能感兴趣的文章:

相关文章