点击查看代码
import time,os
def timestamp_to_string(timestamp):
vtime = time.localtime(timestamp)
vdatetime=time.strftime('%Y-%m-%d %H:%M:%S',vtime)
return vdatetime
def bytetoM(size):
vsize = size/float(1024*1024)
return round(vsize,2)
if __name__ == "__main__":
fileinfo = os.stat("./binary_tree.docx")
print("binary_tree.docx的信息:")
print("文件建立时间:",timestamp_to_string(fileinfo.st_ctime))
print("文件的大小:",bytetoM(fileinfo.st_size),'M')
print("文件的修改是时间:",timestamp_to_string(fileinfo.st_mtime))
print("文件的访问时间:",timestamp_to_string(fileinfo.st_atime))