os.path.join函数的第二个参数开头不能是
"/"
,否则路径无法正常添加。
def check(output_txt='./data/pred/pred_output.txt'):
cur_path = os.getcwd()
print(cur_path)
print(output_txt)
pred_output_txt = os.path.join(cur_path, output_txt)
print(pred_output_txt)
check()
"""
G:\...\system\joint_model
./data/pred/pred_output.txt
G:/data/pred/pred_output.txt
"""
def check(output_txt='data/pred/pred_output.txt'):
cur_path = os.getcwd()
print(cur_path)
print(output_txt)
pred_output_txt = os.path.join(cur_path, output_txt)
print(pred_output_txt)
check()
"""
G:\...\system\joint_model
data/pred/pred_output.txt
G:\...\system\joint_model\data/pred/pred_output.txt
"""