“Argumen baris perintah dalam debugging Python” Kode Jawaban

Argumen baris perintah dalam debugging 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

Argumen baris perintah dalam debugging 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

Jawaban yang mirip dengan “Argumen baris perintah dalam debugging Python”

Pertanyaan yang mirip dengan “Argumen baris perintah dalam debugging Python”

Lebih banyak jawaban terkait untuk “Argumen baris perintah dalam debugging Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya