代码人生进程

个人写的
暂时只能找python的代码吼吼
看来还有很长的路要走

import easygui as g,sys,os
list1=[]
def seach_file(path):#OK
    os.chdir(path)
    for each_file in os.listdir():
        if os.path.splitext(each_file)[1]=='.py':
            list1.append(os.getcwd()+'\\'+each_file)
        elif os.path.isdir(each_file):
            seach_file(each_file)
            os.chdir(os.pardir)

    
def print_all(x,y,jd):
    a='您目前写了%s行代码,完成进度%s\n'%(str(y),str(jd))+'离10万行代码还差%s,加油啊啊啊啊啊!'%(str(1e6-y))
    msg='【.py】源文件%s个,源代码%s行'%(str(x),str(y))
    g.textbox(msg=a,title='统计结果',text=msg)
    
    
def main():
    path=g.diropenbox('请选择主目录')
    seach_file(path)
    count=0
    n=0
    for each_file in list1:
        n+=1#文件数
        with open(each_file,encoding='UTF-8') as f:
            for line in f.readlines():
                count+=1#总行数
    jd=(count/1e6)*100
    jd=str(jd)+'%'
    print_all(n,count,jd)
        
        
main()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值