python 获取运行文件的路径

import  sys,os
BASE_DIR=os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
sys.path.append(BASE_DIR)
print(BASE_DIR) #D:\pycode

猜你喜欢

转载自blog.csdn.net/ljwy1234/article/details/83418910