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))

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-24
  • 2022-01-31
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
相关资源
相似解决方案