#!/usr/bin/python # -*- coding: utf-8 -*- import os,datetime crd = os.getcwd() files = os.listdir(crd) for fi in files: mt = os.stat(os.path.join(crd,fi)).st_mtime d_mt = datetime.datetime.fromtimestamp(mt) print d_mt.strftime('%Y-%m-%d %H:%M:%S')[0:10]
获取文件/文件夹属性:
import os finfor = os.stat('C:\aa\aa2.py') print finfor #返回: nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0L, st_nlink=0, st_uid=0, st_gid=0, st_size=40L, st_atime=1462412494L, st_mtime=1462413154L, st_ctime=1462412494L)