# 输入指定年月yy = int(input("输入年份: "))mm = int(input("输入月份: "))
# 显示日历print(calendar.month(yy,mm))
import redef command_add(date, event_details, calendar):
'''
Add event_details to the list at calendar[date]
Create date if it was not there
:param date: A string date formatted as "YYYY-MM-DD"
:param event_details: A string describing the event
:param calendars: The calendars database
:return: a string indicating any errors, "" for no errors
'''
try:
p = re.compile(r"\d{4}-\d{2}-\d{2}")
assert p.match(date), "Param date must match YYYY-MM-DD"
assert isinstance(event_details, str), \
"Param event_details must be a string"
if date in calendar:
calendar[date].append(str(event_details))
else:
calendar.update({date: str(event_details)})
except Exception,e:
return str(e)
def main():
calendar = {}
command_add("2015-10-20", "Python class", calendar)
print calendar
command_add("2015-11-01", "go out with friends after test",
calendar)
print calendar
if __name__ == "__main__":
main()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)