Calendar module in Python has the calendar class that allows the calculations for various task based on date, month, and year. On top of it, the TextCalendar and HTMLCalendar class in Python allows you to edit the calendar and use as per your requirement. Let see what we can do with Python Calendar. Step1 : Code Line # 1: We begin with "import calendar" which will import all the classes of this module. Code Line # 3: c= calendar.TextCalendar(calendar.SUNDAY) tells the interpreter to create a text calendar. Start of the month will be Sunday. In Python, you can format the calendar as you can change the day of the month to begin with Code Line # 4: str= c.formatmonth(2015,1) We are creating calendar for the year 2015, Month 1 – January Code Line # 5: print str will print the output. Run the code. Let's quickly change the value from Sunday to Thursday and check the output Step 2 : You can also print out the Calendar in HTML format, this feature is helpful...
Comments
Post a Comment