Pass data as a string to argparse in Python: unrecognized argument

I am trying to parse date as an argument in Python with argparse:

def parsing(parser):
    parser.add_argument("--b", type=str)
    parser.add_argument("--e", type=str)
    return parser

parser = argparse.ArgumentParser()
parser = parsing(parser)
args = parser.parse_args()

I’m trying to execute it with:

python –-b 20100101 –-e 20200120

But I am getting a “unrecognized argument” error. I have also tried removing the type=str, but I get the same error. UserWarning: loaded more than 1 DLL from .libs: 

C:Usersuserminiconda3libsite-packagesnumpy.libslibopenblas.WCDJNK7YVMPZQ2ME2ZZHJJRJ3JIKNDB7.gfortran-win_amd64.dll warnings.warn("loaded more than 1 DLL from .libs:" usage: [-h] [--b B] [--e E] error: unrecognized arguments: –-b 20100101 –-e 20200120


The error is in this line.

python –-b 20100101 –-e 20200120

one of the ‘-‘ is a different character.

python --b 20100101 --e 20200120

This works.

Leave a Reply

Your email address will not be published. Required fields are marked *