博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python代码—— 获取文件夹下文件个数
阅读量:680 次
发布时间:2019-03-17

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

import ospath = r"J:\data\Annotations"fileList = os.listdir(path)  # 待修改文件夹print(str(fileList))os.chdir(path)  # 将当前工作目录修改为待修改文件夹的位置num = 0 # 名称变量for fileName in fileList:  # 遍历文件夹中所有文件    num += 1print(num)

转载地址:http://nwdhz.baihongyu.com/

你可能感兴趣的文章