Created
January 31, 2019 12:25
-
-
Save 01x01/8b4d45be5868b2e50e76e5ad628962d6 to your computer and use it in GitHub Desktop.
This file contains 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
# coding:utf-8 | |
import argparse | |
parser = argparse.ArgumentParser() | |
mandatory = parser.add_argument_group("Mandatory") | |
mandatory.add_argument('-u','--url',help="URL Target",action="store",type=str,dest="urldest",default=None) | |
dictionary = parser.add_argument_group("Dictionary") | |
dictionary.add_argument('-w','--wordlist',action="store",type=str,dest="wordlist",default="None") | |
parser.print_help() | |
args = parser.parse_args() | |
# ---使用方法--- | |
# args.urldest===> 取到 url 这个参数 | |
# 如果不存在,则为 None | |
# ---参数--- | |
# 第一个参数为 flag | |
# 第二个参数为 name | |
# action: 一般值为 store 代表存储这个参数值 | |
# type: 这个参数的类型,一般有 str / int / float | |
# dest: 这个参数是你需要使用的时候,需要args.dest来调用这个参数,算是对象的属性名 | |
# metavar:举例说明这个参数的用法,比如说,日期格式为:YYYY-MM-DD | |
# choices: 提供一个数组,这个参数的值将会从数组中选取 | |
# required:参数是否是必须的,这个是一个可选的,可以在这里判断,或者在程序中判断 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment