无法在CMD中加载Python脚本的参数

2024-04-23 21:03:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我在尝试从这个Python脚本加载图像时遇到了麻烦。 在Windows10中运行良好。我不知道为什么它不能在我的Windows7系统中工作。你知道吗

from __future__ import print_function
import argparse
import cv2

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required = True,
            help = "Path to the image")
args = vars(ap.parse_args())

image = cv2.imread(args["image"])

在我跑步的时候

showimage.py --image syiling.png

然后它就回来了

showimage.py error argument is required

enter image description here


Tags: py图像imageimport脚本系统requiredargparse