Visual Studio Code:如何使用参数调试 Python 脚本 [英] Visual Studio Code: How debug Python script with arguments

查看:53
本文介绍了Visual Studio Code:如何使用参数调试 Python 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Visual Studio Code 来调试 Python 脚本.

遵循

但是当我按下 Debug 时,它说我的参数不被识别,Visual Studio Code 说:

<块引用>

错误:无法识别的参数

由于 Visual Studio Code 使用 PowerShell,让我们使用相同的参数执行相同的文件:

所以:相同的文件、相同的路径和相同的参数.它在终端中工作,但在 Visual Studio Code 中不工作.

我哪里错了?

解决方案

我认为 --City 和 Auckland 被用作单个参数.也许尝试像这样将它们分开...

单参数

 "args": ["--ci​​ty","Auckland"]

多个参数和多个值

例如:

--key1 value1 value2 --key2 value3 value4

只需将它们一一放入args列表依次:

args":[--key1"、value1"、value2"、--key2"、value3"、value4"]

I'm using Visual Studio Code in order to debug a Python script.

Following this guide, I set up the argument in the launch.json file:

But when I press on Debug, it says that my argument is not recognized and Visual Studio Code says:

error: unrecognized arguments

As Visual Studio Code is using PowerShell, let's execute the same file with the same argument:

So: the same file, same path, and same argument. In the terminal it is working, but not in Visual Studio Code.

Where am I wrong?

解决方案

I think the --City and Auckland are used as a single argument. Maybe try separating them like so...

Single argument

    "args": ["--city","Auckland"]

Multiple arguments and multiple values

Such as:

--key1 value1 value2 --key2 value3 value4

Just put them into the args list one by one in sequence:

"args": ["--key1", "value1", "value2", "--key2", "value3", "value4"]

这篇关于Visual Studio Code:如何使用参数调试 Python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆