相关疑难解决方法(0)

vscode 可以使用 Properties/launchSettings.json 中的配置文件吗?

有没有办法将“.vscode/launch.json”指向“Properties/launchSettings.json”中定义的配置文件,这样我就不需要重复这些值?

我需要支持几种不同的编辑器,并且还需要从命令行运行

dotnet run --launch-profile="myprofile"
Run Code Online (Sandbox Code Playgroud)

visual-studio-code asp.net-core asp.net-core-webapi

10
推荐指数
1
解决办法
8626
查看次数

Python错误:需要以下参数

我有通过命令行执行它时运行良好的 Python 脚本。我想要做的是将此脚本导入另一个 python 文件并从那里运行它。

问题是初始脚本需要参数。它们的定义如下:

#file one.py
def main(*args):
   import argparse

   parser = argparse.ArgumentParser(description='MyApp')
   parser.add_argument('-o','--output',dest='output', help='Output file image', default='output.png')
   parser.add_argument('files', metavar='IMAGE', nargs='+', help='Input image file(s)')

   a = parser.parse_args()
Run Code Online (Sandbox Code Playgroud)

我将此脚本导入另一个文件并传递了参数:

#file two.py
import one
one.main('-o file.png', 'image1.png', 'image2.png')
Run Code Online (Sandbox Code Playgroud)

但是虽然我将输入图像定义为参数,但仍然出现以下错误:

usage: two.py [-h] [-o OUTPUT] 
          IMAGE [IMAGE ...]
two.py: error: the following arguments are required: IMAGE
Run Code Online (Sandbox Code Playgroud)

python args python-import argparse

5
推荐指数
1
解决办法
5万
查看次数