本文整理汇总了Python中schedule.Schedule.validateTerm方法的典型用法代码示例。如果您正苦于以下问题:Python Schedule.validateTerm方法的具体用法?Python Schedule.validateTerm怎么用?Python Schedule.validateTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类schedule.Schedule
的用法示例。
在下文中一共展示了Schedule.validateTerm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleInput
# 需要导入模块: from schedule import Schedule [as 别名]
# 或者: from schedule.Schedule import validateTerm [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