본문 바로가기
file, directory

Python - folder 제거(remove) with os(import)

by space father python 2022. 12. 29.
반응형

Code

1
2
3
4
5
6
7
8
import os
 
dir_path = 'D:\\new_folder'
if os.path.exists(dir_path):
    os.rmdir(dir_path)
    print(f"removed folder: {dir_path}")
else:
    print(f'There is no {dir_path}')
cs

 

Result

#> python .\folder_remove.py
removed folder: D:\new_folder