Using Python 3 pathlib on Windows, is there a way to deal with folders that start with a number, other than adding an extra slash?
For example:
from pathlib import Path, PureWindowsPath
op = pathlib.Path("D:\Documents\01")
fn = "test.txt"
fp = outpath / fn
with fp.open("w", encoding ="utf-8") as f:
f.write(result)
Returns error: [Errno 22] Invalid argument: 'D:\\Documents\x01\\test.txt'
I would have thought the PureWindowsPath would have taken care of this. If I manually escape out of it with op = pathlib.Path("D:\Documents\\01"), then it is fine. Do I always have to manually add a backslash to avoid the escape?