Python TextCalendar.prmonth() 方法
prmonth() 方法是内置的方法TextCalendar
类calendar
Python 中的模块。它适用于文本日历。它使用 TextCalendar 类的实例并打印给定年份的月份。此外,无需编写 "print" 操作。
模块:
import calendar
类:
from calendar import TextCalendar
用法:
prmonth(year, month, w=0, l=0)
参数:
year
:它是一个必需参数,它指定日历的年份。month
:它是一个必需参数,它指定日历的月份。w
: 可选参数,指定日期列的宽度;默认值 = 0。l
: 它是一个可选参数,表示一周将在结果字符串中使用的行数,默认值 = 0。
返回值:
这个方法的返回类型是<class 'NoneType'>
,它打印给定年份月份的相应日历。
例:
# Python program to illustrate the
# use of prmonth() method
# import class
import calendar
# creating a TextCalendar instance
cal = calendar.TextCalendar()
year = 2019
month = 12
print("Printing December 2019 calendar with default paramters, w = 0, l = 0")
cal.prmonth(year, month)
print()
# Setting width=3
cal = calendar.TextCalendar()
year = 1919
month = 1
print("Printing January 1919 calendar with w = 3")
cal.prmonth(year, month, 3)
print()
# Setting width=5 length of one line=2
cal = calendar.TextCalendar()
year = 1999
month = 11
print("Printing November 1999 calendar with w = 3, l = 2")
cal.prmonth(year, month, 3, 2)
print()
# Changing the firstweekday
cal = calendar.TextCalendar(firstweekday = 4)
# First column will be Friday
year = 2005
month = 5
print("Printing May 2005 calendar with w = 3, l = 1 and first column starting with Friday")
cal.prmonth(year, month, 3, 1)
print()
输出
Printing December 2019 calendar with default paramters, w = 0, l = 0 December 2019 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 Printing January 1919 calendar with w = 3 January 1919 Mon Tue Wed Thu Fri Sat Sun 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 Printing November 1999 calendar with w = 3, l = 2 November 1999 Mon Tue Wed Thu Fri Sat Sun 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 Printing May 2005 calendar with w = 3, l = 1 and first column starting with Friday May 2005 Fri Sat Sun Mon Tue Wed Thu 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
相关用法
- Python TextCalendar pryear()用法及代码示例
- Python TextCalendar formatyear()用法及代码示例
- Python TextCalendar formatmonth()用法及代码示例
- Python TextBlob.correct()用法及代码示例
- Python TextBlob.Word.spellcheck()用法及代码示例
- Python TextBlob.noun_phrases()用法及代码示例
- Python TextBlob.word_counts()用法及代码示例
- Python TextBlob.sentiment()用法及代码示例
- Python Tensorflow asin()用法及代码示例
- Python Tensorflow nn.sigmoid()用法及代码示例
- Python Tensorflow math.accumulate_n()用法及代码示例
- Python Tensorflow cosh()用法及代码示例
- Python Tensorflow acos()用法及代码示例
- Python Tensorflow asinh()用法及代码示例
- Python Tensorflow nn.softplus()用法及代码示例
- Python Tensorflow exp()用法及代码示例
- Python Tensorflow logical_and()用法及代码示例
- Python Tensorflow logical_or()用法及代码示例
- Python Tensorflow atanh()用法及代码示例
- Python Tensorflow bitwise.bitwise_and()用法及代码示例
注:本文由纯净天空筛选整理自 Python TextCalendar Class | prmonth() Method with Example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。