pythonvisual-studio-codecommand-linevscode-debuggersys

When debugging in VS Code, it doesn't take command inputs for Python


While debugging in VS Code, I am trying to give command lines but it doesn't take any and it moves directly to input(). Here len(sys.argv) is always equal to one.

I saw an old question which was exactly about the same, but it didn't help.

In watch it says len(sys.argv)=1 and it doesn't take any input

enter image description here


Solution

  • Add "args": ["arg1", "arg2", "arg3"] to your launch.json if you want to pass some values.

    This configuration ensures that sys.argv will contain the specified arguments when your script runs in the debugger.

    Read document about args for more details.