os只能删除empty的文件夹。
因此:

import shutil
shutil.rmtree(dirpath)