如何修复Python中的错误“无法识别的参数”?

时间:2019-05-02 15:02:38

标签: python-3.x argparse

在Internet上,我找到了将代码(bmp)转换成矩阵的代码。该错误表明bmp图片是无法识别的参数。

from scipy import *
import argparse
import os
if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Convert an image into a matrix. The output is a binary file <img>.npy in the same directory as the input image.')
    parser.add_argument('img',help="C:\\Users\\DELL\\PycharmProjects\\untitled.py\\baboon.bmp")
    args = parser.parse_args("baboon.bmp")
    img_path = args.img
    img_array = misc.imread(img_path)
    save(os.path.splitext(img_path)[0]+'-matrix', img_array)

0 个答案:

没有答案