有没有办法将“.vscode/launch.json”指向“Properties/launchSettings.json”中定义的配置文件,这样我就不需要重复这些值?
我需要支持几种不同的编辑器,并且还需要从命令行运行
dotnet run --launch-profile="myprofile"
Run Code Online (Sandbox Code Playgroud) 我有通过命令行执行它时运行良好的 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)