Skip to content

Instantly share code, notes, and snippets.

@Huarong
Last active December 23, 2016 01:21
Show Gist options
  • Select an option

  • Save Huarong/5882697 to your computer and use it in GitHub Desktop.

Select an option

Save Huarong/5882697 to your computer and use it in GitHub Desktop.
Python: parse command arguments with argparse module example
def parse_cmd_args():
parser = argparse.ArgumentParser(description='run the procedure of advice opinion extraction')
parser.add_argument('config', help='config file path')
parser.add_argument('-b', '--begin', type=int, default=-1, help='The process step to begin')
parser.add_argument('-e', '--end', type=int, default=-1, help='The process step to end')
parser.add_argument('-t', '--test', action='store_true', help='Indicate test or not')
args = parser.parse_args()
return args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment