首页 > 其他 > 详细

用计数循环实现,每隔10行写到新文件中

时间:2017-06-13 16:16:15      阅读:340      评论:0      收藏:0      [点我收藏+]

 

 

 

# coding:utf-8        
with open(‘dist_1.txt‘,‘r‘,encoding= ‘utf-8‘) as f1,open(‘dist_2.txt‘,‘w‘,encoding= ‘utf-8‘) as f2:
    i=0
    for line in f1:
        i+=1
        if i%10==0:
            f2.write(line) 

 

用计数循环实现,每隔10行写到新文件中

原文:http://www.cnblogs.com/kearney908/p/7001166.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!