相对引用:
from ..base import xx
详细原因请参考:https://www.cnblogs.com/jiaxin359/p/7580375.html
用sys.path.append
# coding=utf-8
import sys
import os
CURRENT_DIR = os.path.split(os.path.abspath(__file__))[0] # 当前目录
config_path = CURRENT_DIR.rsplit('/', 3)[0] # 上三级目录
sys.path.append(config_path)
from config import param
print('config_path=', config_path)
print(sys.path)
print(param)
用path这个包
import path, sys
folder = path.path(__file__).abspath()
sys.path.append(folder.parent.parent)