博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
统计文件夹下文件总数
阅读量:7045 次
发布时间:2019-06-28

本文共 383 字,大约阅读时间需要 1 分钟。

  hot3.png

import oscount = 0path = r'C:\Users\xxxx\Desktop\top'for root, dirs, files in os.walk(path):    #print files    fileLength = len(files)    if fileLength != 0:        count = count + fileLengthprint "The number of files under <%s> is: %d" %(path,count)

上面是程序是 统计 C:\Users\xxxx\Desktop\top 目录下文件的个数 使用的时候 将 path 替换为想要的就行了 注意 path 等号 后面的 ‘r’

转载于:https://my.oschina.net/jeffyu/blog/93080

你可能感兴趣的文章
基于fedora16的nagios环境搭建--个人日记(8)--cacti安装
查看>>
我的友情链接
查看>>
Hibernate技术
查看>>
ElasticSearch API for JAVA 学习笔记
查看>>
我的友情链接
查看>>
记事本程序
查看>>
linux下单引号、双引号、反引号用法
查看>>
发展FiOS业务 提升用户上网速度
查看>>
学科前沿技术作业七
查看>>
java.lang.Exception: org.apache.http.conn.ConnectTimeoutException:
查看>>
java 像素小鸟
查看>>
jquery中的数组过滤筛选-$.grep()
查看>>
我的友情链接
查看>>
surface
查看>>
高级运维工程师的打怪升级之路
查看>>
Mysql的一些优化(my.cnf)
查看>>
让ie支持阴影、圆角和渐变
查看>>
Debian下Apache配置多域名访问
查看>>
volatile关键字应用之外设寄存器
查看>>
PowerShell检测并添加用户权限
查看>>