kingrangE

파일의 개수를 구해야 하는 순간에 쓰는 Python 코드입니다.

 

os.listdir()을 이용하여 폴더 안에 있는 파일들의 list를 가져온 후, list의 길이를 측정하는 방식으로 폴더 안의 파일의 개수를 구할 수 있습니다.

import os

folder_path = "/desktop/example/" 
file_list = os.listdir(folder_path)
fileNumber = len(file_list)

print(fileNumber)

 

 

 

profile

kingrangE

@전길원

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!