赞
踩
遇到一个基础的常识问题,出错信息见下;
os.remove(os.path.dirname(dst_path))\nIsADirectoryError: [Errno 21] Is a directory:
报错原因为:remove 删除的是文件,不能用来删除文件夹;
如果要删除空的文件夹,使用 os.rmdir()
如果要删除非空的文件夹,类似于linux的 “rm -rf”命令,使用shutil
import shutil
shutil.rmtree(‘dirpath’)
有问题欢迎随时交流~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。