Python文件路径空格问题

创建文件夹的时候,后面没有加 ‘/’,到循环体中再加,报错。

    predict_res_save_path = 'predict_results/' + time.strftime("%Y_%m_%d_%H_%M_%S ", time.localtime()) 
    if not os.path.exists('predict_res_save_path'):
        print(os.path.exists('predict_res_save_path'))
        os.makedirs(predict_res_save_path)
    for i in range(brast.n_test_file):
        save_path = predict_res_save_path +  ‘/’ + brast.test_name_list[i] + '.npy'
        print('ok')
        x, y = brast.next_test_batch_3d_slider(slider_size=[64, 64, 64])
        predict_res = model.predict(x, batch_size=1)
        np.save(save_path, predict_res)
        loss, dice_coef = model.evaluate(x, y, batch_size=1)
        print('\ntest loss', loss)
        print('dice_coef', dice_coef)

错误信息提示我找不到某个文件,仔细观察,发现在’/'之前有个空格
找不到路径

    predict_res_save_path = 'predict_results/' + time.strftime("%Y_%m_%d_%H_%M_%S ", time.localtime()) + '/'
    if not os.path.exists('predict_res_save_path'):
        print(os.path.exists('predict_res_save_path'))
        os.makedirs(predict_res_save_path)
    for i in range(brast.n_test_file):
        save_path = predict_res_save_path + brast.test_name_list[i] + '.npy'
        print('ok')
        x, y = brast.next_test_batch_3d_slider(slider_size=[64, 64, 64])
        predict_res = model.predict(x, batch_size=1)
        np.save(save_path, predict_res)
        loss, dice_coef = model.evaluate(x, y, batch_size=1)
        print('\ntest loss', loss)
        print('dice_coef', dice_coef)

这个代码就可以找到
正确验证

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值