获取文件大小,结果保留两位小数,单位为M
import os
def Get_Size(fpath):
fsize = os.path.getsize(fpath)
fsize = fsize/float(1024*1024)
return round(fsize,2)
获取文件访问时间
def Time_localtime(timestamp):
stime = time.localtime(timestamp)
return time.strftime('%Y-%m-%d %H:%M:%S',stime)
def Get_AccessTime(fpath):
t = os.path.getatime(fpath)
return Time_localtime(t)
获取文件创建时间
def Time_localtime(timestamp):
stime = time.localtime(timestamp)
return time.strftime('%Y-%m-%d %H:%M:%S',stime)
def Get_CreatTime(fpath):
t = os.path.getctime(fpath)
return Time_localtime(t)
获取文件修改时间
def Time_localtime(timestamp):
stime = time.localtime(timestamp)
return time.strftime('%Y-%m-%d %H:%M:%S',stime)
def Get_ModifyTime(fpath):
t = os.path.getmtime(fpath)
return Time_localtime(t)
网友评论