import os
import sys
# print(os.path.dirname(os.path.abspath(__file__)))
# sys.exit(-1)
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(root_dir)
def get_file_path(relative_path):
return os.path.join(root_dir, relative_path)
if __name__ == '__main__':
print(get_file_path('common/path_utils.py'))
#为啥要这么做
#比如说你们开发是在windows机器上: D:\heima_creazy_05\04_code\chinese_medical_project_all_project_for_heima_crazy_05\common/path_utils.py
#上线的时候 部署了 linux 机器: /home/heima_creazy_05/04_code/chinese_medical_project_all_project_for_heima_crazy_05/common/path_utils.py
#如果 你把代码中的路径写死了,上线的时候,就需要到处改代码