현재_디렉터리_얻기,gettting_current_directory

현재_디렉터리_얻기,gettting_current_directory (rev. 1.4)

current directory = working directory

파이썬,Python에서 현재 디렉터리 / 작업 디렉터리


를 얻는 방법
import os
os.getcwd()

를 바꾸는 방법
os.chdir("/some/directory")



Sub:
subdirectory

트리,tree 구조.
filesystem / file_system의 구성 요소.
파일,file들을 담고 있음.

Python에서 하위 directory들을 훑으려면 os.walk() 함수를 사용.
for root, dirs, files in os.walk(os.getcwd()):
    print(files)

그 중 특정 확장자 파일만 찾고 싶다면,
for root, dir, files in os.walk(os.getcwd()):
    for f in files:
        a = os.path.splitext(f)[-1]
        if a == ‘.xml’:
            print(f)


}