Language/Python
[Python] 폴더에 있는 파일 목록 확인하기
물장구질
2021. 7. 19. 12:00
1. glob 이용
import glob
# 폴더에 있는 모든 파일 경로 가져오기
all_files = glob.glob("/test/temp/*")
# 폴더에 있는 text 파일 경로만 가져오기
text_files = glob.glob("/test/temp/*.txt")
# 폴더에 있는 json 파일 경로만 가져오기
json_files = glob.glob("/test/temp/*.json")