Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 根据丢失的信息调整异常消息_Python_Python 2.7_Python 2.x_Command Line Arguments - Fatal编程技术网

Python 根据丢失的信息调整异常消息

Python 根据丢失的信息调整异常消息,python,python-2.7,python-2.x,command-line-arguments,Python,Python 2.7,Python 2.x,Command Line Arguments,有这样的代码: if __name__ == "__main__": parser.add_argument("--u_shape_dict", default="", action='store', help="required for ...") parser.add_argument("--v_shape_dict", default="", action='store', help="req

有这样的代码:

if __name__ == "__main__":
    parser.add_argument("--u_shape_dict", default="", action='store',
                    help="required for ...")

    parser.add_argument("--v_shape_dict", default="", action='store',
                    help="required for ...")

    u_shape_dict = args['u_shape_dict']
    if not u_shape_dict:
        raise Exception('u_shape_dict is missing. Please provide it')

    v_shape_dict = args['v_shape_dict']
    if not v_shape_dict:
        raise Exception('v_shape_dict is missing. Please provide it')
我想将这两个例外合并为一个,如下所示:

if not u_shape_dict or v_shape_dict:
    raise Exception('%s is missing. Please provide it' % )
有可能吗? 在
%
符号之后,我实际需要放什么?

您应该使用该选项,argparse将负责错误报告您应该使用该选项,argparse将负责错误报告您应该使用该选项,argparse将负责错误报告您应该使用该选项,argparse将负责错误报告