Skip to content

Instantly share code, notes, and snippets.

@xmeng1
Created September 18, 2019 17:01
Show Gist options
  • Save xmeng1/3090ca364377d56c81f34cc3d2a2ca66 to your computer and use it in GitHub Desktop.
Save xmeng1/3090ca364377d56c81f34cc3d2a2ca66 to your computer and use it in GitHub Desktop.
parser.py
from __future__ import print_function
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--color', help='The name of the color')
parser.add_argument('--verbose', help='Print more data',
action='store_true')
parser.add_argument('--cuda', '-c', default=True, action='store_false')
args = parser.parse_args()
def main():
global args
args = parser.parse_args()
print(args.color)
print(args.verbose)
print(args.cuda)
if args.cuda:
print("xxx")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment