python 統(tǒng)計(jì)代碼行數(shù)簡(jiǎn)單實(shí)例
python 統(tǒng)計(jì)代碼行數(shù)簡(jiǎn)單實(shí)例
送測(cè)的時(shí)候,發(fā)現(xiàn)需要統(tǒng)計(jì)代碼行數(shù)
于是寫(xiě)了個(gè)小程序統(tǒng)計(jì)自己的代碼的行數(shù)。
#calclate_code_lines.py import os def afileline(f_path): res = 0 f = open(f_path) for lines in f: if lines.split(): res += 1 return res if __name__=='__main__': host = 'E:'+os.sep+'develop'+os.sep+'dev_workspace'+os.sep+'AptanaStudio3'+os.sep+'webhost' allfiles = 0 allline = 0 for root,dirs,files in os.walk(host): for afile in files: if(root.startswith(host+os.sep+'entries')): continue elif(root.startswith(host+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'.settings')): continue elif(root.startswith(host+os.sep+'logs')): continue elif(root.startswith(host+os.sep+'static')): continue elif(root.startswith(host+os.sep+'payload'+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'dist'+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'dsync'+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'hcache'+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'test'+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'webhost'+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'wsgi'+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'hcache'+os.sep+'templates'+os.sep+'.svn')): continue elif(root.startswith(host+os.sep+'dsync'+os.sep+'hcache'+os.sep+'.svn')): continue else: ext = afile.split('.') ext = ext[-1] if (ext in ['py','css','js','html','txt','docx','wsgi']): itpath = root+os.sep+afile allfiles += 1 allline +=afileline(itpath) print (root+os.sep+afile) print ('Total: ',allfiles) print ('Total lines:',allline)
之后可以將此改造下便于以后的代碼統(tǒng)計(jì)
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- python實(shí)現(xiàn)統(tǒng)計(jì)代碼行數(shù)的小工具
- python統(tǒng)計(jì)指定目錄內(nèi)文件的代碼行數(shù)
- python實(shí)現(xiàn)代碼統(tǒng)計(jì)器
- python實(shí)現(xiàn)代碼統(tǒng)計(jì)程序
- python tkinter圖形界面代碼統(tǒng)計(jì)工具(更新)
- python3使用GUI統(tǒng)計(jì)代碼量
- python tkinter圖形界面代碼統(tǒng)計(jì)工具
- 使用Python設(shè)計(jì)一個(gè)代碼統(tǒng)計(jì)工具
- Python實(shí)現(xiàn)統(tǒng)計(jì)代碼行的方法分析
- Python實(shí)現(xiàn)代碼統(tǒng)計(jì)工具
相關(guān)文章
python GUI庫(kù)圖形界面開(kāi)發(fā)之PyQt5窗口背景與不規(guī)則窗口實(shí)例
這篇文章主要介紹了python GUI庫(kù)圖形界面開(kāi)發(fā)之PyQt5窗口背景與不規(guī)則窗口實(shí)例,需要的朋友可以參考下2020-02-02python結(jié)合API實(shí)現(xiàn)即時(shí)天氣信息
這篇文章主要介紹了python結(jié)合API實(shí)現(xiàn)即時(shí)天氣信息的代碼,非常的實(shí)用,有需要的小伙伴可以參考下。2016-01-01Pycharm安裝第三方庫(kù)并更換鏡像的詳細(xì)教程
在使用pycharm學(xué)習(xí)python的時(shí)候,經(jīng)常需要第三方庫(kù),沒(méi)有第三方庫(kù)程序就會(huì)報(bào)錯(cuò),pycharm也會(huì)提醒你要安裝所需要的庫(kù),下面這篇文章主要給大家介紹了關(guān)于Pycharm安裝第三方庫(kù)并更換鏡像的詳細(xì)教程,需要的朋友可以參考下2023-05-05使用celery執(zhí)行Django串行異步任務(wù)的方法步驟
這篇文章主要介紹了使用celery執(zhí)行Django串行異步任務(wù),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Django具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06Python實(shí)現(xiàn)輕松識(shí)別數(shù)百個(gè)快遞單號(hào)
當(dāng)我們要寄出很多快遞時(shí),為了及時(shí)反饋物流信息,需要盡快將快遞單號(hào)提取出來(lái)。這時(shí)用手動(dòng)去識(shí)別真的太麻煩,所以本文將用Python實(shí)現(xiàn)輕松識(shí)別數(shù)百個(gè)快遞單號(hào),需要的可以參考一下2022-06-06python結(jié)合shell自動(dòng)創(chuàng)建kafka的連接器實(shí)戰(zhàn)教程
這篇文章主要介紹了python結(jié)合shell自動(dòng)創(chuàng)建kafka的連接器,需要安裝連接oracle的python包,獲取oracle表信息,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下2022-04-04linux下python使用sendmail發(fā)送郵件
這篇文章主要為大家詳細(xì)介紹了linux下python使用sendmail發(fā)送郵件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05python實(shí)現(xiàn)爬取千萬(wàn)淘寶商品的方法
這篇文章主要介紹了python實(shí)現(xiàn)爬取千萬(wàn)淘寶商品的方法,涉及Python頁(yè)面抓取的相關(guān)技巧,需要的朋友可以參考下2015-06-06