티스토리 뷰
728x90
반응형
파이썬에서 현재 디렉토리 경로에 있는 jpg 이미지파일명 목록으로 가져와 읽는방법입니다.
import os
# 현재 디렉토리 경로를 가져옴
current_directory = os.getcwd()
# 현재 디렉토리에 있는 파일 목록을 가져옴
files_in_directory = os.listdir(current_directory)
# .jpg 확장자로 끝나는 파일만 필터링
jpg_files = [file for file in files_in_directory if file.lower().endswith('.jpg')]
print("현재 디렉토리 경로:", current_directory)
print("JPG 파일 목록:")
for file in jpg_files:
my_image = Image.open(file)
728x90
반응형
'프로그래밍 > Python' 카테고리의 다른 글
[오류해결] raise OSError(f"cannot write mode {im.mode} as JPEG") from eOSError: cannot write mode RGBA as JPEG (0) | 2024.07.02 |
---|---|
[pymongo] pymongo MongoClient 데이터베이스, 컬렉션명 출력하기 (0) | 2024.06.26 |
[Python] 파이썬에서 진행률(progress 바) 출력하는 방법 (42) | 2024.01.08 |
python3.x 원하는 버전의 pip 설치하기 (0) | 2023.09.01 |
[mongoDB] 맥북에 몽고DB 설치하는 방법 (1) | 2023.07.14 |
댓글