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')

 

posted @ 2016-10-13 22:08  梅子472  阅读(109)  评论(0编辑  收藏  举报