“Argumenty linii poleceń w debugowaniu Pythona” Kod odpowiedzi

Argumenty linii poleceń w debugowaniu Pythona

# 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

Argumenty linii poleceń w debugowaniu Pythona

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

Odpowiedzi podobne do “Argumenty linii poleceń w debugowaniu Pythona”

Pytania podobne do “Argumenty linii poleceń w debugowaniu Pythona”

Więcej pokrewnych odpowiedzi na “Argumenty linii poleceń w debugowaniu Pythona” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu