파일과 디렉터리 액세스¶
이 장에서 설명하는 모듈은 디스크 파일과 디렉터리를 다룹니다. 예를 들어, 파일의 속성을 읽고, 이식성 있는 방식으로 경로를 조작하고, 임시 파일을 만드는 모듈이 있습니다. 이 장의 전체 모듈 목록은 다음과 같습니다:
pathlib
— Object-oriented filesystem paths- 기본 사용
- Exceptions
- 순수한 경로
- 구상 경로
- Pattern language
- Comparison to the
glob
module - Comparison to the
os
andos.path
modules
os.path
— Common pathname manipulationsabspath()
basename()
commonpath()
commonprefix()
dirname()
exists()
lexists()
expanduser()
expandvars()
getatime()
getmtime()
getctime()
getsize()
isabs()
isfile()
isdir()
isjunction()
islink()
ismount()
isdevdrive()
isreserved()
join()
normcase()
normpath()
realpath()
relpath()
samefile()
sameopenfile()
samestat()
split()
splitdrive()
splitroot()
splitext()
supports_unicode_filenames
fileinput
— Iterate over lines from multiple input streamsstat
— Interpretingstat()
resultsS_ISDIR()
S_ISCHR()
S_ISBLK()
S_ISREG()
S_ISFIFO()
S_ISLNK()
S_ISSOCK()
S_ISDOOR()
S_ISPORT()
S_ISWHT()
S_IMODE()
S_IFMT()
filemode()
ST_MODE
ST_INO
ST_DEV
ST_NLINK
ST_UID
ST_GID
ST_SIZE
ST_ATIME
ST_MTIME
ST_CTIME
S_IFSOCK
S_IFLNK
S_IFREG
S_IFBLK
S_IFDIR
S_IFCHR
S_IFIFO
S_IFDOOR
S_IFPORT
S_IFWHT
S_ISUID
S_ISGID
S_ISVTX
S_IRWXU
S_IRUSR
S_IWUSR
S_IXUSR
S_IRWXG
S_IRGRP
S_IWGRP
S_IXGRP
S_IRWXO
S_IROTH
S_IWOTH
S_IXOTH
S_ENFMT
S_IREAD
S_IWRITE
S_IEXEC
UF_SETTABLE
UF_NODUMP
UF_IMMUTABLE
UF_APPEND
UF_OPAQUE
UF_NOUNLINK
UF_COMPRESSED
UF_TRACKED
UF_DATAVAULT
UF_HIDDEN
SF_SETTABLE
SF_SUPPORTED
SF_SYNTHETIC
SF_ARCHIVED
SF_IMMUTABLE
SF_APPEND
SF_RESTRICTED
SF_NOUNLINK
SF_SNAPSHOT
SF_FIRMLINK
SF_DATALESS
FILE_ATTRIBUTE_ARCHIVE
FILE_ATTRIBUTE_COMPRESSED
FILE_ATTRIBUTE_DEVICE
FILE_ATTRIBUTE_DIRECTORY
FILE_ATTRIBUTE_ENCRYPTED
FILE_ATTRIBUTE_HIDDEN
FILE_ATTRIBUTE_INTEGRITY_STREAM
FILE_ATTRIBUTE_NORMAL
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
FILE_ATTRIBUTE_NO_SCRUB_DATA
FILE_ATTRIBUTE_OFFLINE
FILE_ATTRIBUTE_READONLY
FILE_ATTRIBUTE_REPARSE_POINT
FILE_ATTRIBUTE_SPARSE_FILE
FILE_ATTRIBUTE_SYSTEM
FILE_ATTRIBUTE_TEMPORARY
FILE_ATTRIBUTE_VIRTUAL
IO_REPARSE_TAG_SYMLINK
IO_REPARSE_TAG_MOUNT_POINT
IO_REPARSE_TAG_APPEXECLINK
filecmp
— File and Directory Comparisonstempfile
— Generate temporary files and directoriesglob
— Unix style pathname pattern expansionfnmatch
— Unix filename pattern matchinglinecache
— Random access to text linesshutil
— High-level file operations