Python TextCalendar: formatmonth() method
formatmonth() method
The formatmonth() method is used to get a month's calendar in a multi-line string.
Syntax:
formatmonth(theyear, themonth, w=0, l=0)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
theyear | Year for which the calendar should be generated. | Required | Number |
themonth | Month for which the calendar should be generated. | Required | Number |
w | Specifies the width of the date columns, which are centered. Default value is 0. | Optional | Number |
l | Specifies the number of lines that each week will use. Default value is 0. | Optional | Number |
Example of Text-calendar-formatmonth() method
import calendar
tc= calendar.TextCalendar(firstweekday=0)
print(tc.formatmonth(2016, 5))
Output:
May 2016 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Previous: yeardayscalendar()
Next: prmonth()
Test your Python skills with w3resource's quiz
Python: Tips of the Day
How to make a chain of function decorators?
from functools import wraps def makebold(fn): @wraps(fn) def wrapped(*args, **kwargs): return "<b>" + fn(*args, **kwargs) + "</b>" return wrapped def makeitalic(fn): @wraps(fn) def wrapped(*args, **kwargs): return "<i>" + fn(*args, **kwargs) + "</i>" return wrapped @makebold @makeitalic def hello(): return "hello world" @makebold @makeitalic def log(s): return s print hello() # returns "<b><i>hello world</i></b>" print hello.__name__ # with functools.wraps() this returns "hello" print log('hello') # returns "<b><i>hello</i></b>"
Ref: https://bit.ly/3cVz5iw
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework