1
收藏
def filescount(filepath):
import os
files = os.listdir(filepath)
txtcount = 0
filecount = 0
pycount = 0
pdfcount = 0
jpecount = 0
for each in files:
(name,extension) = os.path.splitext(each)
if extension == '.txt':
txtcount +=1
elif extension =='.py':
pycount += 1
elif extension =='.JPG':
jpecount +=1
elif extension == '.pdf':
pdfcount += 1
else:
filecount += 1
print('该文件夹下共有类型为【.txt】的文件 %d 个' % txtcount)
print('该文件夹下共有类型为【.PDF】的文件 %d 个' % pdfcount)
print('该文件夹下共有类型为【.py】的文件 %d 个' % pycount)
print('该文件夹下共有类型为【.JPG】的文件 %d 个' % jpecount)
print('该文件夹下共有类型为文件夹的文件 %d 个' % filecount)
filepath = input('请输入文件路径:')
filescount(filepath)
def filescount(filepath):
import os
file = os.listdir(filepath)
for each in file:
if each != '$RECYCLE.BIN':
if each != 'System Volume Information':
m = filepath + each
size = os.path.getsize(m)
print(each,size)
filepath = input('请输入文件路径:')
filescount(filepath)
{:10_256:}
东西很多呢,一个一个试验一下也很难啊
感谢小甲鱼
专业的让人两眼冒金星
顶起来,学到了!!
感谢!
666
{:10_266:}
悄悄的给了个赞
666
sdf
留名
努力的学习中,{:10_269:}
谢谢大佬
学习中。。。
收藏了~
很好很详细