하고재비

[python] 디렉토리에 특정파일 찾기 본문

Python

[python] 디렉토리에 특정파일 찾기

DeadDE 2017. 12. 1. 16:20
import os

def search(dirname):
try:
filenames = os.listdir(dirname)
for filename in filenames:
full_filename = os.path.join(dirname, filename)
if os.path.isdir(full_filename):
search(full_filename)
else:
ext = os.path.splitext(full_filename)[-1]
if ext == '.py':
print(full_filename)

except PermissionError:
pass
search("C:/")

if ext == '.py':


'Python' 카테고리의 다른 글

[PYTHON] 크롤링  (0) 2017.12.08
[python] list 선언  (0) 2017.12.01
[python]꺽은선 그래프  (0) 2017.12.01
[Python]객체  (0) 2017.11.10
[Python] Dict 총정리  (0) 2017.10.23
Comments