“Arguments de ligne de commande dans le débogage python” Réponses codées

Arguments de ligne de commande dans le débogage python

# In vscode you need to click on the screw in the debugging sidepanel.
# It will open up a json file with some text already written there.
# Example:
# Let's say I have a script named script.py
# which takes 2 arguments, path to file and a boolean verbose

# Normally we would write something like this in the terminal:
# python script.py --filename=foo.txt --verbose
# In the json, you pass them in a list as follows:
"args": ["--filename", "foo.txt", "--verbose"]
# Notice that you drop the "=" and
# write --filename and foo.txt as separate list entries
Burouj Armgaan

Arguments de ligne de commande dans le débogage python

The steps are shown in the image linked here:

https://i.stack.imgur.com/Hx5tf.png

Go to debug mode in VS Code
Click on the settings icon (gear icon). If it does not exist this will create a launch.json
In the json, in any of the configuration, add the args json parameter:
{
    "name": "Python: Terminal (integrated)",
    "type": "python",
    "request": "launch",
    "stopOnEntry": true,
    "pythonPath": "${config:python.pythonPath}",
    "program": "${file}",
    "cwd": "",
    "console": "integratedTerminal",
    "env": {},
    "args": [
        "input2.csv",
        "output2.csv"
    ],
    "envFile": "${workspaceFolder}/.env",
    "debugOptions": [],
    "internalConsoleOptions": "neverOpen"
}
Burouj Armgaan

Réponses similaires à “Arguments de ligne de commande dans le débogage python”

Questions similaires à “Arguments de ligne de commande dans le débogage python”

Plus de réponses similaires à “Arguments de ligne de commande dans le débogage python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code