告别年代

阳光里闪耀的色彩真美丽

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 
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))

 

posted on 2018-07-28 16:49  告别年代  阅读(163)  评论(0编辑  收藏  举报