[python]디렉토리 내 파일 및 폴더 리스트를 반환하고플 때!

건너별·2022년 7월 5일
0

python

목록 보기
12/12
  1. os.listdir
  • 모든 파일 및 디렉토리
  1. os.walk
  • 디렉토리 및 하위 디렉토리
  1. os.scandir
  • 파일 attribute info를 포함한 디렉토리 정보를 담은 객체를 반환
  1. glob : 특정 확장자의 파일들 리스트를 추려낼 수 있음
  • 아래와 같은 구조인 경우

    content
    │   /content/12306315121-120-012.mid
    │   /content/12306316121-120-012.mid 
    └──	meta.csv
import glob

path = r'/content/*.mid'

glob.glob(path)

>>>
['/content/12306315121-120-012.mid', '/content/12306316121-120-012.mid']

Reference

profile
romantic ai developer

0개의 댓글