반응형
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 |
'file, directory' 카테고리의 다른 글
Python - with open 파일 쓰기 (file write) (0) | 2022.12.30 |
---|---|
Python - file 제거(remove) with os(import) (0) | 2022.12.29 |