ITPub博客

首页 > 应用开发 > Java > python选项参数

python选项参数

原创 Java 作者:zhaohang3031 时间:2009-03-04 10:26:58 0 删除 编辑

#!c:python26python.exe
import optparse

def main():
MSG_USAGE = "opt.py [-s ][-p ]"
p = optparse.OptionParser(MSG_USAGE)
p.add_option('-s','--server',default="127.0.0.1",help="Server ip your self with this option.")
p.add_option('-p','--port',default="6666",type="int",help="Server port your self with this option.")
p.add_option('-c','--client',default="localhost",help="Client ip your self with this option.")
options, arguments = p.parse_args()
print 'Server: %snPort: %snClient: %s' % (options.server,options.port,options.client)

if __name__ == '__main__':
main()

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16362696/viewspace-1018057/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    1
  • 访问量
    1294