1

I'm trying to get the current directory using the OS module, like that:

directory=os.getcwd()

However, when I do this, the directory comes with \, like 'C:\Users\...', and I need to use directory with \\ or /.

Is that anyway to get the directory with \\ or /?

1 Answers1

3

You can just replace the \ with /. Note that the former must be escaped with another \, like below:

import os
directory = os.getcwd().replace('\\', '/')
PApostol
  • 2,152
  • 2
  • 11
  • 21