Example Analysis of python option parameters
This article will explain in detail the example analysis of python option parameters for everyone, Xiaobian thinks it is quite practical, so share it for everyone to make a reference, I hope you can gain something after reading this article.
#! 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@]
About "python option parameter example analysis" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.