Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Generate a Calendar

Python Generate a Calendar

Document Object Reference Manual Python3 Examples

The following code generates the calendar for a specified date:

Example (Python 3.0+)

Filename : test.py

author by : www.runoob.com

Import the calendar module

import

calendar

Enter the specified year and month

yy

=

int

(

input

(

"

Enter a year:

"

)

)

mm

=

int

(

input

(

"

Enter the month:

"

)

)

Displays a calendar

print

(

calendar

.

month

(

yy

,

mm

)

)

The output of the code above is:


输入年份: 2015
输入月份: 6
     June 2015
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

Document Object Reference Manual Python3 Examples