■ glob 함수를 사용해 입력 경로의 모든 파일 및 디렉토리 리스트를 구하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 |
import glob list1 = glob.glob("c:\\windows\\*.exe") print(list1) r""" ['c:\\windows\\bfsvc.exe', 'c:\\windows\\explorer.exe', 'c:\\windows\\HelpPane.exe', 'c:\\windows\\hh.exe', 'c:\\windows\\notepad.exe', 'c:\\windows\\py.exe', 'c:\\windows\\pyw.exe', 'c:\\windows\\regedit.exe', 'c:\\windows\\splwow64.exe', 'c:\\windows\\Twunk_16.exe', 'c:\\windows\\Twunk_32.exe', 'c:\\windows\\winhlp32.exe', 'c:\\windows\\write.exe'] """ |
※ 입력 경로 내에서 *와 ?도 사용 가능하며 [과 ]를 사용한 문자열 비교도 가능하다.