Stop argparse from globbing filepath

前端 未结 3 1985
北恋
北恋 2021-01-12 23:08

I am using python argparse with the following argument definition:

parser.add_argument(\'path\', nargs=1, help=\'File path to process\')

Bu

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 23:43

    The shell is expanding the wildcard argument before argparse gets a chance to see it. Put quotes around the wildcard argument to prevent the shell from expanding it.

    You could later perform the wildcard expansion with glob.glob.

提交回复
热议问题