0

Context:

Working in Visual Studio Community 2019, developping a Python script which needs arguments (a figure between 1 and 3).

So, I configured the debugger to do so like this: enter image description here

In my Python script, i tried to print this argument:

print(str(date.today()) + " Argument Value :" + str(sys.argv))

Issue:

I got this in the console:

Argument Value: ['PathTo\MyScriptName.py', '1']

How should i do to get only the argument without the path of the script ?

1 Answer 1

1

sys.argv[1]. sys.argv is a list. You should check that it has 2 (or more) elements first, but sys.argv[0] will always be the path of your script.

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

Comments

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.