디렉토리내 모든 dir, file 삭제

기린이·2021년 8월 23일
0

모아두기🔧

목록 보기
7/39

하............ colab에서 함부로 압축푸는 거 아니다,,

os.scandir

an iterator of os.DirEntry objects
.path하면 객체의 전체경로를 알 수 있다. os.path.join 범벅 안될 수 있음

for file in os.scandir('/content/eval'):
  if os.path.isdir(file.path):
    os.rmdir(file.path)
  else:
    os.remove(file.path)
profile
중요한 것은 속력이 아니라 방향성, 공부하며 메모를 남기는 공간입니다.

0개의 댓글