直接上代码吧
# coding=utf-8
import argparse
import textwrap
import sys
__author__ = 'HATE_'
def getargs():
# * A high-efficiency automatic program used for cracking Apache Tomcat\'s log-on credential, Powered by Tank *
parser = argparse.ArgumentParser(prog='example.py', formatter_class=argparse.RawTextHelpFormatter, description=textwrap.dedent('''
For Example:
python example.py --host 127.0.0.1:8080 --threads 10'''))
parser.add_argument('--host', metavar='host', type=str, help=' the host of target,including port')
parser.add_argument('--threads', metavar='threads', type=int, help=' The numbers of threads per process')
if(len(sys.argv[1:]) == 0):
sys.argv.append('-h')
return parser.parse_args()
if __name__ == '__main__':
paramsargs = getargs()
print paramsargs.host
print paramsargs.threads
C:\Users\test\Desktop>python search
usage: example.py [-h] [--host host] [--threads threads]
For Example:
python example.py --host 127.0.0.1:8080 --threads 10
optional arguments:
-h, --help show this help message and exit
--host host the host of target,including port
--threads threads The numbers of threads per process