[python] 파일의 생성 시간, 수정 시간, 접근 시간 확인하기

먼저, 파일의 경로를 가지고 파일의 생성 시간, 수정 시간, 접근 시간을 확인할 수 있습니다. 이를 위해서는 os.path 모듈과 os.stat 함수를 사용합니다. 아래는 파일 경로를 입력받아 파일의 생성 시간, 수정 시간, 접근 시간을 확인하는 예제 코드입니다.

import os
import time

file_path = '파일의 경로를 입력하세요'  # 파일의 경로를 지정합니다

# 파일의 생성 시간, 수정 시간, 접근 시간을 확인합니다
file_stat = os.stat(file_path)
creation_time = time.ctime(file_stat.st_ctime)
modification_time = time.ctime(file_stat.st_mtime)
access_time = time.ctime(file_stat.st_atime)

print(f'파일 생성 시간: {creation_time}')
print(f'파일 수정 시간: {modification_time}')
print(f'파일 접근 시간: {access_time}')

이 코드를 실행하면 해당 파일의 생성 시간, 수정 시간, 접근 시간이 출력됩니다.

이 방법을 통해 Python에서 파일의 생성 시간, 수정 시간, 접근 시간을 확인할 수 있습니다.