import os,time filePath='test.txt' # 获取文件创建时间戳 print(os.path.getctime(filePath)) # 获取文件的修改时间戳 print(os.path.getmtime(filePath)) # 获取文件的访问时间戳 print(os.path.getatime(filePath)) # 转换为时间 def TimeStampToTime(timestamp): timeStruct = time.localtime(timestamp) return time.strftime('%Y-%m-%d %H:%M:%S', timeStruct) print(TimeStampToTime(os.path.getatime(filePath))) print(TimeStampToTime(os.path.getctime(filePath))) print(TimeStampToTime(os.path.getmtime(filePath)))
标签:各个,查看,filePath,Python,time,print,path,os,TimeStampToTime From: https://www.cnblogs.com/lucktomato/p/16709004.html