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:
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 ?
CodePudding user response:
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.