软著源码粘贴助手

文本文件汇集

import os
# 遍历文件夹
file=r'F:\cms-mgmt\cms-mgmt\src\main'

suma=0
content=''
for root, dirs,files in os.walk(file):
    if suma>3050:
        break
    # 遍历文件
    for f in files:         
        if suma>3050:
            break
        if os.path.join(root, f)[-4:]=='java':
            try:
                with open(os.path.join(root, f),'r',encoding='utf8',errors='ignore') as f0:
                    for  line in  f0.readlines(): 
                        if len(line)!='\n':
                            content+=line.strip()+'\n'
                            suma+=1
                print(os.path.join(root, f))
            except:
                pass
# content.replace('\n\n','\n')            
with open(file+'\Source code.txt','a',encoding='utf8') as f1:
    f1.write(content)      

posted on 2020-03-20 18:35  耀扬  阅读(426)  评论(0编辑  收藏  举报

导航