python 获取文件创建日期、修改日期 Get created & modified time of a file
2017-06-10 10:48
1211 查看
To update the filename according to its created time or modified time, a function is a good way.
And with simple change of variables:
Both of which return date in yyyy-mm-dd format.
def getMdate(file): '''return: modified time of a file''' import time # os.stat return properties of a file tmpTime = time.localtime(os.stat(file).st_mtime) return time.strftime('%Y-%m-%d', tmpTime)
And with simple change of variables:
def getCdate(file): '''return: created time of a file''' import time # os.stat return properties of a file tmpTime = time.localtime(os.stat(file).st_ctime) return time.strftime('%Y-%m-%d', tmpTime)
Both of which return date in yyyy-mm-dd format.
相关文章推荐
- Python3基础 getatime getctime getmtime 获取一个文件的最近访问时间 创建时间 最新修改时间
- python脚本获取文件的创建于修改日期并计算时间差
- python文件夹遍历,文件操作,获取文件修改创建时间<转>
- python文件夹遍历,文件操作,获取文件修改创建时间
- How to get the size of file in C++ - 在C++中如何获取文件的大小
- python文件夹遍历,文件操作,获取文件修改创建时间
- C#使用file无法修改netware操作系统下的文件创建日期
- PHP中获取文件创建日期、修改日期、访问时间的方法
- 牛客网Java刷题知识点之File对象常用功能:获取文件名称、获取文件路径、获取文件大小、获取文件修改时间、创建与删除、判断、重命名、查看系统根目录、容量获取、获取某个目录下内容、过滤器
- Windows API ——GetFileTime——获取文件时间
- Windows API ——GetFileTime——获取文件时间
- How to get the file's icon using C++ - 用C++如何获取文件的图标
- Get and display the size of file and directory in Linux system using du command 获取和现实linux文件大小(三)
- python文件夹遍历,文件操作,获取文件修改创建时间
- python文件夹遍历,文件操作,获取文件修改创建时间
- WINDOWS API ——GETFILETIME——获取文件时间
- JavaSE8基础 File lastModified 获取文件夹的修改日期
- python获取文件修改时间与创建时间
- s 获取input type="file" 选择的文件大小、文件名称、上次修改时间、类型等信息
- python文件夹遍历,文件操作,获取文件修改创建时间