from optparse import OptionParser
usage = "python test.py [history] [index] [account] [userprofile] [only_ace|tradehero] --userid=2222 --startdate='2014-06-13'"
parser = OptionParser(usage=usage)
parser.add_option("--startdate",dest='startdate')
parser.add_option("--userid",dest='userid')
(options,args) = parser.parse_args()
print options (--userid=2222 --startdate='2014-06-13')
print args ([history] [index] [account] [userprofile] [only_ace|tradehero])
本文介绍了一个使用Python的optparse模块解析命令行参数的例子。通过定义选项并获取用户输入的日期和ID,展示了如何处理命令行输入并打印解析后的结果。
1354

被折叠的 条评论
为什么被折叠?



