특정 디렉토리를 입력하면 하위디렉토리의 리스트를 나타내는 코드입니다.

예를 들어 디렉토리명에 '/'을 입력하면 root디렉토리 하위의 모든 디렉토리명을 리스트로 반환하고

'/root'를 입력하면 /root 밑의 모든 하위 디렉토리를 리스트로 반환합니다. 인용은 stackoverflow.com입니다

import os 

def listdir_fullpath(d):
   
return [os.path.join(d, f) for f in os.listdir(d)]

listdir_fullpath('/')

>> import py_compile

>> py_compile.compile('test.py')

>> quit

냉무

+ Recent posts