国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

用于統計項目中代碼總行數的Python腳本分享

2020-01-04 19:17:28
字體:
來源:轉載
供稿:網友

最近需要統計一下項目中代碼的總行數,寫了一個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)

關于代碼上的分析就到這里,例子比較簡單。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 枝江市| 菏泽市| 湖北省| 张家口市| 定州市| 诸城市| 鄂托克旗| 吐鲁番市| 东光县| 木兰县| 徐州市| 垦利县| 潮安县| 赤壁市| 龙江县| 临沧市| 瑞安市| 高清| 碌曲县| 凤阳县| 丽水市| 丹江口市| 肃宁县| 鱼台县| 泸定县| 安龙县| 穆棱市| 探索| 桂东县| 江陵县| 东丽区| 景洪市| 安阳市| 镇赉县| 芷江| 扎兰屯市| 台安县| 平顺县| 西华县| 曲靖市| 赫章县|