PYTHON 列出指定目录下的文件
2011-10-08 10:14
441 查看
import os import re import time dir = "." type = "txt" files = os.listdir( dir ) rr = re.compile( "\.%s{1}quot; %type , re.I ) for f in files: if rr.search(f): info = os.stat( f ) print "File : [%s]" %f ctime = time.localtime( info.st_ctime ) print "\tCreation Time:%s" %(str(ctime[0])+"-"+str(ctime[1])+"-"+str(ctime[2])+" "+str(ctime[3])+":"+str(ctime[4])+":"+str(ctime[5])) print "\tFile Size : %s bytes\n" %info.st_size
======
执行结果:
File : [hotmail.js.txt]
Creation Time : 2008-11-21 14:48:13
File Size : 543 bytes
File : [seven.txt]
Creation Time : 2009-9-8 23:30:35
File Size : 2017 bytes
相关文章推荐
- python 列出指定目录下指定拓展名的文件
- Python列出当前目录下所有含有指定名称的文件(包括路径)
- python列出目录下指定文件与子目录的方法
- python列出指定目录下的所有目录和文件
- python 列出指定目录下的所有目录和文件
- python列出目录下指定文件与子目录的方法
- Python获取指定目录下文件数量及总大小
- python 将目下的excel全部转xml文件到指定的目录
- Python备份文件到指定目录下
- Python: 从 指定地址 下载文件 到 本地目录(附源码)
- python工具程序一、复制目录中指定扩展名的文件
- python小练——找出指定目录下小于指定字节的文件,输出到文本文件
- python清除指定目录内所有文件中script的方法
- python清除指定目录内所有文件中script的方法
- Python:在指定目录下查找满足条件的文件
- 树型结构列出指定目录里所有文件的PHP类
- dos批处理:列出指定目录下所有文件
- python ( os , path , sys ) 找出指定目录下的所有文件,并求出大小且排序
- 列出指定目录下后缀是.mp3的所有文件
- python 从指定目录获取文件