【问题标题】:Why is the os.path.join() in directory giving an invalid directory name error?为什么目录中的 os.path.join() 会给出无效的目录名称错误?
【发布时间】:2021-05-11 19:52:14
【问题描述】:

这里它应该创建一个命名模型 1 的文件夹,但它给出了一个错误消息。

# Folder for tensorboard
folder_name = f'Model 1 at {strftime("%H:%M")}'
directory = os.path.join('tensorboard_mnist_digit_logs', folder_name)
try:
    os.makedirs(directory)
except OSError as exception:
    print(exception.strerror)
else:
    print('Successfully created directories!')

【问题讨论】:

  • Windows 上的目录名称中不能有冒号 :。它只能直接出现在驱动器号之后。

标签: python tensorflow2.0 tensorboard


【解决方案1】:

您不能在文件夹名称中包含':'

更改strftime("%H:%M") to strftime("%H-%M") 就可以了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-20
    相关资源
    最近更新 更多