python 路径

atm---main.py
import os ,sys
print(__file__)
print(os.path.abspath(__file__))#绝对路径
print(os.path.dirname(os.path.abspath(__file__))) #相对路径
bash=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(bash)

from config import settings
settings.sayhi()

config--settings.py

def sayhi():
    print('hello')
原文地址:https://www.cnblogs.com/xuehuahongmei/p/5958355.html