def get_input_mode(mode_description_ls, input_tips=None):
    """
    获取输入，并根据 mode_description_ls 返回选择的 mode
    :param mode_description_ls: 第一个item为默认模式 [[mode, description], ……]
    description 为对应的输入
    :param input_tips: 不设定时将根据 mode_description_ls 自动生成
    """

    description_mode_dict = {str(description): str(mode) for mode, description in mode_description_ls}
    if not input_tips:
        input_tips = "pls choose %s(%s|default)" % (mode_description_ls[0][0], mode_description_ls[0][1])
        for mode, description in mode_description_ls[1:]:
            input_tips += "/%s(%s)" % (mode, description)
        input_tips += " mode:\n"
    while True:
        input_str = input(input_tips)
        try:
            if not input_str:  # 输入""使用默认值
                mode = str(mode_description_ls[0][0])
            else:
                mode = description_mode_dict.get(input_str, None)
                if mode is None:
                    print("ERR:input value exceeds range!")
                    continue
            print("Mode %s is selected" % mode)
            break
        except Exception as e:
            print(Exception, ":", e)
    return mode