728x90
반응형
728x170
import os
def Search(sourceDirectory):
try:
fileNameList = os.listdir(sourceDirectory)
for fileName in fileNameList:
filePath = os.path.join(sourceDirectory, fileName)
if os.path.isdir(filePath):
Search(filePath)
else:
fileExtension = os.path.splitext(filePath)[-1]
if fileExtension == ".py":
print(filePath)
except PermissionError:
pass
Search("c:\\")
728x90
반응형
그리드형(광고전용)
'Python > os' 카테고리의 다른 글
[PYTHON/OS] commonprefix 함수 : 공통 경로 구하기 (0) | 2022.09.13 |
---|---|
[PYTHON/OS] basename 함수 : 파일/디렉토리 경로의 기본 이름 구하기 (0) | 2022.09.13 |
[PYTHON/OS] abspath 함수 : 현재 경로와 파일/디렉토리 경로를 사용해 절대 경로 구하기 (0) | 2022.09.13 |
[PYTHON/OS] expanduser 함수 : 사용자 계정 디렉토리 구하기 (0) | 2018.07.26 |
[PYTHON/OS] walk 함수 : 파일 확장자가 ".py" 파일인 경우 출력하기 (0) | 2017.12.16 |
[PYTHON/OS] isdir 함수 : 디렉토리 여부 구하기 (0) | 2017.12.16 |
[PYTHON/OS] splitext 함수 : 파일 확장자 구하기 (0) | 2017.12.16 |
[PYTHON/OS] join 함수 : 파일 경로 구하기 (0) | 2017.12.16 |
[PYTHON/OS] listdir 함수 : 해당 디렉토리의 서브 디렉토리와 파일 리스트 구하기 (0) | 2017.12.16 |
[PYTHON/OS] rename 함수 : 파일명 변경하기 (0) | 2017.12.15 |
댓글을 달아 주세요