Python查看文件各个时间
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)))
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号