Is there a way to create a file and automatically create its path?
for example:
with open("./path/to/file/data.txt", "w") as f:
f.write("hello")
I want it to create the path ./path/to/file and then create the file data.txt and open it.
instead it will give the error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: './path/to/file/data.txt'
I don't want to have to manually create the path one folder at a time.