示例如下:
# -*- coding: utf-8 -*-
import os
import sys
import time
reload(sys)
sys.setdefaultencoding('utf8')
path = u"D:\VPN\代码\数据仓库存储过程修改备份"
for root, dir, files in os.walk(path):
for file in files:
full_path = os.path.join(root, file)
#print(full_path)
#print(file)
mtime = os.stat(full_path).st_mtime
file_modify_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(mtime))
print("{0} 修改时间是: {1}".format(full_path,file_modify_time))
输出结果:
C:\Users\Administrator\Anaconda3\envs\lineage_relation\python.exe D:/python_project/test_db_python/svn_test/check_updated_svn_file.py
D:\VPN\代码\数据仓库存储过程修改备份\PKG_DIM\PKG_DIM_20180625_YJT_1.pck 修改时间是: 2018-06-25 18:15:53
D:\VPN\代码\数据仓库存储过程修改备份\PKG_DM\PKG_DM_20180709_LYL_1.pck 修改时间是: 2018-07-11 07:36:40
D:\VPN\代码\数据仓库存储过程修改备份\PKG_DM\PKG_DM_20180709_LYL_1.~pck 修改时间是: 2018-07-11 07:36:40
该博客主要围绕Python展开,介绍了使用Python遍历文件并获取其修改时间的相关内容,虽未给出详细代码和更多细节,但明确了核心操作。
402

被折叠的 条评论
为什么被折叠?



