














import os, datetimefrom datetime import date
from pathlib import Pathfile_path = "C:\\Users\\mengchen.shao\\Desktop\\BET"
path = Path(file_path)
for file in path.iterdir():
creation_time = os.path.getctime(file)
update_time = os.path.getmtime(file)
cre_date = datetime.datetime.fromtimestamp(creation_time).date()
upd_date = datetime.datetime.fromtimestamp(update_time).date()
today = date.today()
print(f"{file}文件的创建时间:{(today - cre_date).days}")
print(f"{file}文件的更新时间:{(today - upd_date).days}")
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。