I'm having troubles creating directories when concatenating one or more strings as part of the filename. As an example:
DIR = r"D:/My/Directory"
classes = ['itemA', 'itemB']
for item in classes:
for scope in ["training/", "testing/"]:
os.mkdir(os.path.join(DIR, scope + item))
Creates the error:
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'D:/My/Directory\\training/itemA'
The os.mkdir
works when I'm not using scope + item
, but when I do it throws this error. I'm not sure how the function handles training/itemA
differently than trainingitemA
when they are both interpreted as a string literal.