网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 用于统计项目中代码总行数的Python脚本分享
范文
    这篇文章主要介绍了用于统计项目中代码总行数的Python脚本分享,本文直接给出实现代码,需要的朋友可以参考下
    最近需要统计一下项目中代码的总行数,写了一个Python小程序,不得不说Python是多么的简洁,如果用Java写至少是现在代码的2倍。
    [code]
    import os
    path="/Users/rony/workspace/ecommerce/ecommerce/hot-deploy/"
    global totalcount
    totalcount =0
    def cfile (path):
    allfiles = os.listdir(path)
    for file in allfiles:
    child = os.path.join(path,file)
    if os.path.isdir(child):
    cfile(child)
    else:
    filename,fileext= os.path.splitext(child)
    print(fileext)
    #file type need to calculate
    if fileext in ['.java', '.jsp', '.html', '.htm', '.xml', '.sql', '.js', '.ftl', '.css','.groovy'] :
    countf = len(open(child,'rU').readlines())
    global totalcount
    totalcount=totalcount+countf;
    print(child)
    print(countf)
    cfile(path)
    print(totalcount)
    关于代码上的分析就到这里,例子比较简单。
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/18 11:03:22