import os

def delete_empty_folders(path='.'):
    # 倒序遍历所有文件夹，确保从最深层开始删除
    for root, dirs, files in os.walk(path, topdown=False):
        for dir_name in dirs:
            full_path = os.path.join(root, dir_name)
            try:
                # 检查是否为空文件夹
                if not os.listdir(full_path):
                    os.rmdir(full_path)
                    print(f"✅ 成功删除空文件夹: {full_path}")
            except Exception as e:
                print(f"❌ 无法删除: {full_path}，错误: {e}")

if __name__ == "__main__":
    delete_empty_folders()
