当前位置: 首页>>代码示例>>Python>>正文


Python Schedule.validateCourse方法代码示例

本文整理汇总了Python中schedule.Schedule.validateCourse方法的典型用法代码示例。如果您正苦于以下问题:Python Schedule.validateCourse方法的具体用法?Python Schedule.validateCourse怎么用?Python Schedule.validateCourse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在schedule.Schedule的用法示例。


在下文中一共展示了Schedule.validateCourse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handleInput

# 需要导入模块: from schedule import Schedule [as 别名]
# 或者: from schedule.Schedule import validateCourse [as 别名]
def handleInput(info):
    """
    Handles prompting for user input and validating user input. The results of
    valid input are stored in the info dictionary.

    :param info: where user input is stored
    :returns: whether or not the program should close
    """
    term = None

    # Get which term will be used.
    try:
        term = input("Enter your desired term (example: FA16): ")
    except:
        print("")

        return True

    # Validate the format of the term.
    while not Schedule.validateTerm(term):
        term = input("You have entered an invalid term, try again: ")

    # Get all the desired courses.
    print("Enter all of your desired classes on a separate line.")
    print("To finish entering classes, input an empty line.")

    courses = []

    while True:
        try:
            course = input()

            if course:
                if Schedule.validateCourse(course):
                    courses.append(course.upper())
                else:
                    print("'" + course + "' is not a valid course code.")
            else:
                break
        except KeyboardInterrupt:
            return True
        except:
            break

    # Validate if any courses were entered.
    if len(courses) == 0:
        print("You did not enter any courses.")

        return True

    # Send the user input to the main function.
    info["term"] = term.upper()
    info["courses"] = courses

    return False
开发者ID:brianhang,项目名称:tritonscheduler,代码行数:57,代码来源:main.py


注:本文中的schedule.Schedule.validateCourse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。