1. Home
  2. Computing & Technology
  3. Python

How To Create A HTML Calendar In Python Dynamically

From , former About.com Guide

7 of 10

Getting the Calendar Data

Now we need to create the actual calendar. To get the actual calendar data, we need the calendar module's monthcalendar() method. This method takes two arguments: the year and the month of the desired calendar (both in integer form). It returns a list which contains lists of the dates of the month by week. So if we count the number of items in the returned value, we have the number of weeks in the given month.

month = calendar.monthcalendar(current_yr, current_no)
nweeks = len(month)

Explore Python
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Python
  4. Web Development
  5. Python and HTML - HTML Calendars in Python - Getting the Calendar Data

©2009 About.com, a part of The New York Times Company.

All rights reserved.