标签:desc 命令行参数 orm choices import port parse position nbsp
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))
标签:desc 命令行参数 orm choices import port parse position nbsp
原文地址:https://www.cnblogs.com/byeyear/p/9382528.html