0

我的代码:

def main():
    usage = "usage: %prog [options] arg"
    parser = OptionParser(usage)
    parser.add_option("-p", "--pending", action="callback", callback=pending, type="string", dest="test", help="View Pending Jobs")
    (options, args) = parser.parse_args()
    if x == 0:
        print usage, " (-h or --help for help)"
    print options.test

如果我有: script -p hello

我需要 options.test 将参数打印为字符串类型

4

2 回答 2

1

参数可通过sys.argv获得。

于 2009-10-13T14:20:29.147 回答
0

最终将参数传递给正在调用的函数。

于 2009-10-13T13:37:46.713 回答