import os
import sys
from pathlib import Path
sys.path.append("..")
current_dir = os.path.abspath(os.path.dirname(__file__))
parent_path = os.path.dirname(current_dir)
grandparent_path = os.path.dirname(parent_path)
grandparent_path_ = os.path.dirname(grandparent_path)
# grandparent_path_to = os.path.dirname(grandparent_path_)
# grandparent_path_to_ = os.path.dirname(grandparent_path_to)
#
# grandparent_path_to_to = os.path.dirname(grandparent_path_to_)
sys.path.append(grandparent_path_)
print(os.path.abspath(__file__))
print(sys.path)
原文:https://www.cnblogs.com/leifzhang/p/15306833.html