zoukankan      html  css  js  c++  java
  • python的命令行参数处理

     
    import argparse
     
    # A position argument
    func_choice = {'client' : 'client function', "server" : "server function"}
    
    # parser
    parser = argparse.ArgumentParser(description = "Select your favorite function")
    # add argument
    parser.add_argument('role', choices = func_choice, help = "select your role")
    parser.add_argument("-p", type = int, help = "select your port")
    
    # parse
    args = parser.parse_args()
    print("You select role {0} and port {1}".format(func_choice[args.role], args.p))
  • 相关阅读:
    Struts2(二)
    jiqixuexi
    UTF-8
    mysql load
    linux命令(转)
    apache FTP站点源码下载
    linux 命令
    clickhouse 查询
    CDH learning
    nfs
  • 原文地址:https://www.cnblogs.com/byeyear/p/9382528.html
Copyright © 2011-2022 走看看