일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- format
- Database
- DB
- TORCH
- LLM
- judge
- KAKAO
- CUDA
- file
- enV
- Linux
- git
- Package
- Flask
- Converting
- Mac
- pytorch
- PostgreSQL
- Python
- AI
- evaluation
- Container
- Laravel
- Paper
- docker
- GitLab
- list
- pandas
- Windows
- numpy
Archives
- Today
- Total
Daily Develope
[Python] 폴더 및 파일 탐색 본문
ㅇ 폴더 및 파일 탐색
- 예) target_dir 에서 png, jpg 파일 출력 (non-recursion)
target_dir = f'{os.getcwd()}/sample'
for root, dirs, files in os.walk(target_dir):
for file in files:
if file.endswith(('.png', 'jpg')):
print(file)
ㅇ 파일 존재 확인
import pathlib
if pathlib.Path('myfile.txt').exists():
print("exists")
'Develope > Python' 카테고리의 다른 글
[Python] 정렬 Sort (Dict, Class) (0) | 2022.04.11 |
---|---|
[Python] Kakao API 사용예시 (0) | 2022.04.11 |
[Python] Numpy 넘파이 함수 정리 (0) | 2022.04.04 |
[Python] MFCC 구현 (0) | 2022.04.04 |
[Python] config 환경설정 관리 및 사용 (0) | 2022.03.31 |