os自帶的刪除文件夾的方式rmdir 和 removedirs只zhen
import os
import shutil
keyword_path = r'D:\star'
if os.path.exists(keyword_path):
shutil.rmtree(keyword_path) # 刪除非空文件夾欧芽,遞歸刪除文件夾
os.mkdir(keyword_path) # 創(chuàng)建文件夾
os.remove(keyword_path) # 刪除文件
os.removedirs(keyword_path) # 刪除空文件夾
os.rmdir(keyword_path) # 刪除空文件夾