📜  在 python 脚本中添加选项 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:41.944000             🧑  作者: Mango

代码示例1
from optparse import OptionParser
...
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
                  help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
                  action="store_false", dest="verbose", default=True,
                  help="don't print status messages to stdout")

(options, args) = parser.parse_args()