import os

print(__file__)
print(os.path.abspath(__file__))
print(os.path.dirname(os.path.abspath(__file__)))
print(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
print(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

print()
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(BASE_DIR);
print(type(os.path.join(BASE_DIR, "templates")))
print(os.path.join(BASE_DIR, "templates"))

print()
print(__name__)

import inspect
print(inspect.getfile(inspect.currentframe()))

-------------------------------------------------------------------------
python shell 에서 하면 안나오고, os cmd에서 해야 한다.
> python xxxx.py

init.py
C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\init.py
C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32
C:\Users\Administrator\AppData\Local\Programs\Python
C:\Users\Administrator\AppData\Local\Programs

C:\Users\Administrator\AppData\Local\Programs\Python
<class 'str'>
C:\Users\Administrator\AppData\Local\Programs\Python\templates

__main__
init.py