0

I have following code:

ap = argparse.ArgumentParser()
ap.add_argument("-o", "--output", required=True, help="path to the output directory")
args = vars(ap.parse_args())
jsonPath = os.path.sep.join([args["output"], "{}.json".format(os.getpid())])
f = open(jsonPath, "w")

I run script with arguments as '--output output'. 'output' directory is at same level as script. I get error as:

FileNotFoundError: [Errno 2] No such file or directory: 'output\xyz.json'

xyz is pid here.

What is correct way of doing it in windows 10?

Mandroid
  • 6,200
  • 12
  • 64
  • 134
  • Possible duplicate of [this question](https://stackoverflow.com/questions/12517451/automatically-creating-directories-with-file-output) – Gerd Oct 21 '19 at 11:29
  • I don't think it's a duplicate. This is a Windows 10 problem, not a python problem. – motorbaby Apr 05 '20 at 20:00

0 Answers0