1 답변
-
수정일 - os.path.getmtime(path)
주어진 경로가 마지막으로 수정된 날을 return합니다. 파일이 존재하지 않거나 접근할 수 없는 경우
os.error
가 발생합니다.import os.path, time print "last modified: %s" % time.ctime(os.path.getmtime(file)) print "created: %s" % time.ctime(os.path.getctime(file))
수정일 - os.stat(path)
파일에 대해 다음과 같은 정보를 담고있는 객체를 return합니다.
- st_mode - protection bits
- st_ino - inode number
- st_dev - device
- st_nlink -
hard link
의 갯수, - st_uid -
owner
의user id
, - st_gid -
owner
의group id
, - st_size - 파일의 크기(byte단위),
- st_atime - 마지막 접속 시간,
- st_mtime - 마지막 수정일,
- st_ctime - 마지막으로 메타데이터가 바뀐 시간(unix), 생성된 날짜(window)
import os fileinfo = os.stat(path) print fileinfo.st_mtime
생성일 - os.path.getctime
import os, time (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(file) print "last modified: %s" % time.ctime(time)
단, linux/unix시스템에서 ctime()은 생성일이 아니라
inode data
가 바뀐 시간을 의미합니다.
댓글 입력