在E:/pythonpachworkspace/study/Django/tango_with_django_project/tango_with_django_project/settings.py文件下测试脚本
import os
print('file是:')
print(__file__)
print("os.path.abspath(__file__):")
print(os.path.abspath(__file__))
print("os.path.dirname(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.abspath(__file__))))
输出结果:
D:\Anaconda3\python.exe E:/pythonpachworkspace/study/Django/tango_with_django_project/tango_with_django_project/settings.py
file是:
E:/pythonpachworkspace/study/Django/tango_with_django_project/tango_with_django_project/settings.py
os.path.abspath(__file__):
E:\pythonpachworkspace\study\Django\tango_with_django_project\tango_with_django_project\settings.py
os.path.dirn