python命令行传参详解,optparse模块OptionParse类的学习
官网链接:https://docs.python.org/3/library/optparse.html
https://docs.python.org/2/library/argparse.html
from optparse import OptionParser parser = OptionParser() parser.add_option("-f", "--file", dest="filename", help="write report to FILE", metavar="FILE") (options, args) = parser.parse_args() print(options,type(options),args,type(args)) #print(type([])) 结果:<class "list">