특정 디렉토리를 입력하면 하위디렉토리의 리스트를 나타내는 코드입니다.
예를 들어 디렉토리명에 '/'을 입력하면 root디렉토리 하위의 모든 디렉토리명을 리스트로 반환하고
'/root'를 입력하면 /root 밑의 모든 하위 디렉토리를 리스트로 반환합니다. 인용은 stackoverflow.com입니다
import os
def listdir_fullpath(d):
return [os.path.join(d, f) for f in os.listdir(d)]
def listdir_fullpath(d):
return [os.path.join(d, f) for f in os.listdir(d)]
listdir_fullpath('/')
'CODE 작성 요청' 카테고리의 다른 글
[파이썬 PYC 파일을 생성하고 싶습니다.] (0) | 2012.09.27 |
---|---|
[서버의 hostname을 가져오는 코드를 만들어주세요] (0) | 2012.09.24 |