为什么目录中的 os.path.join() 给出无效的目录名称错误?

Why is the os.path.join() in directory giving an invalid directory name error?

这里应该创建的文件夹命名为 Model 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!')

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

更改strftime("%H:%M") to strftime("%H-%M"),它将起作用