首页IT科技file folder(File Modification Time | DaniWeb)

file folder(File Modification Time | DaniWeb)

时间2025-06-20 13:22:28分类IT科技浏览4687
导读:The functions are contained in module os. Function os.path.getmtime( gives you the last modified time in seconds since the beginning of 1/1/1970 (epoch . You have to...

The functions are contained in module os. Function os.path.getmtime() gives you the last modified time in seconds since the beginning of 1/1/1970 (epoch). You have to do some formatting with module time functions to make it readable for the ordinary mortal.

The size of the file is returned by os.path.getsize() in bytes, convert to kilobytes and format the result.

import os import time # pick a file you have in the working folder ... fname ="Texture.py" print"File was last modified (12 hour format):" print time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(fname))) fsize = os.path.getsize(fname) print"size = %0.1f kb"%float(fsize/1000.0) """ possible result: File was last modified (12 hour format): 01/25/2003 11:38:30 AM size = 5.8 kb """

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
新建网站怎么收录文件(如何让你的网站在一个月内被搜索引擎收录?)