import glob
import os
data_Path = os.path.join(os.getcwd(), 'data')
# # '*'는 임의 길이의 모든 문자열을 의미한다.
output = glob.glob(data_Path + '/*.txt')
print(output)
print('-' * 20)
# '?'는 한자리의 문자를 의미한다.
output = glob.glob(data_Path + '/temp?.txt')
print(output)
print('-' * 20)
# '[2-3]'은 2~3사이의 숫자를 의미한다.
output = glob.glob(data_Path + '/temp[2~3]?.txt')
print(output)
print('-' * 20)
# recursive=True는 하위경로 검색여부이다.
output = glob.glob(data_Path + '/*.txt', recursive=True)
print(output)
'개발' 카테고리의 다른 글
[Python] Requests를 이용하여 URL 파일 다운로드 저장 (0) | 2022.05.19 |
---|---|
[Python] SMB서버 파일 읽어서 압축 저장하기 (0) | 2022.05.12 |