- 论坛徽章:
- 14
|
本帖最后由 reb00t 于 2015-06-02 10:27 编辑
- import argparse
- import sys
- parser = argparse.ArgumentParser(description="show this help message and exit")
- parser.add_argument("-u", "-username", dest="username", help="username")
- parser.add_argument("-p", "-password", dest="password", nargs='?', help="passwd")
- parser.add_argument("-pid",dest="pid", nargs='?', help="project_id")
- parser.add_argument("-s", "-sub",dest="sub", nargs='?', help="subject")
- args = parser.parse_args()
- if not args.username:
- sys.exit(1)
- username, password, pid, sub = args.username, args.password, args.pid, args.sub
- print username, password, pid, sub
复制代码 |
|