Passing multiple files with asterisk to python shell in Windows

前端 未结 4 2071
忘了有多久
忘了有多久 2020-12-31 05:08

I\'m going through Google\'s Python exercises and I need to be able to do this from the command line:

python babynames.py --summaryfile baby*.html

4条回答
  •  有刺的猬
    2020-12-31 05:34

    Using argparse:

    import argparse
    parser=argparse.ArgumentParser()
    parser.add_argument(dest='wildcard',nargs='+')
    
    print(parser.parse_args().wildcard)
    

提交回复
热议问题