文件
from pathlib import Path print(__file__) print(Path(__file__)) print(Path(__file__).resolve()) print(Path(__file__).resolve().parent.parent)
sys.path.append(str(Path(__file__).resolve().parent.parent))
import sys import os current_work_dir = os.path.dirname(__file__) sys.path.append(os.path.abspath(os.path.join(current_work_dir, '../')))
def delete_folder(folder_path): if os.path.exists(folder_path): for file_name in os.listdir(folder_path): file_path = os.path.join(folder_path, file_name) if os.path.isdir(file_path): delete_folder(file_path) else: os.remove(file_path) os.rmdir(folder_path) else: print(f"{folder_path} not found")