Created
          November 17, 2021 20:19 
        
      - 
      
- 
        Save KrisYu/e7944d16b4bc99a88f6224e342c1eca2 to your computer and use it in GitHub Desktop. 
    command line parse
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # https://stackoverflow.com/questions/15753701/how-can-i-pass-a-list-as-a-command-line-argument-with-argparse | |
| import argparse | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('-i', '--input',type = str, default = "sample.json") | |
| parser.add_argument( "-l","--list", nargs="*", type=int, default=[0,1,2]) | |
| args = parser.parse_args() | |
| print("filename: ", args.input) | |
| print("list:", args.list) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment