0

I run Python file from cmd and I need a path where I opened cmd

C:\Users\test\Desktop\> D:\DEV\test.py

I need C:\Users\test\Desktop\ path

1 Answer 1

2

I'm not sure I fully understand the question but, to get the current working dir for the one containing your script you can use:

import os
print(os.getcwd())

You can find more information in the Python Docs

Sign up to request clarification or add additional context in comments.

1 Comment

@DavidS: Glad it worked! Feel free to accept the answer :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.