2017/08/22
[Python] 특정 경로 탐색
특정 경로의 파일과 폴더를 탐색하는 코드.
import os.path FOLDER = "C:\\MyFolder" print('Current Folder : {0}'.format(FOLDER)) for path, dirs, files in os.walk(FOLDER): print('\nFoler : {0}'.format(path)) for dname in dirs: print('dir: {0}'.format(dname)) for fname in files: print('file: {0}'.format(os.path.join(path, fname)))
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment