python实用小脚本

目录

找到当前目录及其子目录中最大的文件

#!/usr/bin/python
# -*- coding: utf-8 -*-

from os import walk ,getcwd as pwd
from os.path import join, getsize as fsize ,exists 

print reduce(lambda a,b: a[1]>b[1] and a or b, ([f,fsize(f)] for r in walk(pwd()) for f in filter(exists,map(lambda x: join(r[0],x),r[2]))))[0]

目录