print __file__
#返回脚本所在目录import osBASE_DIR = os.path.dirname(os.path.abspath(__file__))print BASE_DIR
#返回脚本所在目录的父目录import osBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))print BASE_DIR
本文共 263 字,大约阅读时间需要 1 分钟。
print __file__
#返回脚本所在目录import osBASE_DIR = os.path.dirname(os.path.abspath(__file__))print BASE_DIR
#返回脚本所在目录的父目录import osBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))print BASE_DIR
转载于:https://www.cnblogs.com/dreamer-fish/p/5198191.html