parser.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:MIT-Hodor 作者: kalbhor 项目源码 文件源码
def timetable(values, data):
    today = calendar.day_name[date.today().weekday()].lower()
    tomorrow = calendar.day_name[(date.today().weekday() + 1) % 7].lower()

    #timetable = values['timetable']
    try:
        time = values['time'][0]['value']
    except KeyError:
        time = 'today'

    if time == 'today':
        time = today
    elif time == 'tomorrow':
        time = tomorrow

    if time == 'sunday':
        return "Sunday is not a working day."

    response = "The timetable for {} is : \n\n ".format(time.upper())

    for subj in data[time]:
        t, sub = subj
        response += "({}) - {} \n\n".format(t,sub)

    if len(data[time]) == 0:
        return "There are no classes or {} is a holiday".format(time.upper())

    return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号