■ walk 함수를 사용해 파일 확장자가 ".py" 파일인 경우 출력하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 |
import os for (directoryPath, subdirectoryList, fileNameList) in os.walk("c:\\"): for fileName in fileNameList: fileExtension = os.path.splitext(fileName)[-1] if fileExtension == ".py": filePath = os.path.join(directoryPath, fileName) print(filePath) |