1.os.path/pathlib # 获得项目根目录 root = pathlib.Path(os.path.abspath(__file__)).parent.parent os.path.abspath(__file__) # 作用: 获取当前脚本的完整路径 # 只有当在脚本中执行的时候,os.path.abspath(__file__)才会起作用 <