博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 示例_Python TextCalendar类别| prmonth()方法与示例
阅读量:2527 次
发布时间:2019-05-11

本文共 3052 字,大约阅读时间需要 10 分钟。

python 示例

Python TextCalendar.prmonth()方法 (Python TextCalendar.prmonth() Method)

prmonth() method is an inbuilt method of the TextCalendar class of calendar module in Python. It works on text calendars. It uses an instance of TextCalendar class and prints the month of the given year. Also, there is no need for writing "print" operation.

prmonth()方法是Python中日历模块的TextCalendar类的内置方法。 它适用于文本日历。 它使用TextCalendar类的实例并打印给定年份的月份。 同样,也不需要编写“打印”操作。

Module:

模块:

import calendar

Class:

类:

from calendar import TextCalendar

Syntax:

句法:

prmonth(year, month, w=0, l=0)

Parameter(s):

参数:

  • year: It is a required parameter, which specifies the year of the calendar.

    year :这是必填参数,用于指定日历的年份。

  • month: It is a required parameter, which specifies the month of the calendar.

    month :这是必填参数,用于指定日历的月份。

  • w: It is an optional parameter, which specifies the width of the date column; default value = 0.

    w :这是一个可选参数,用于指定日期列的宽度; 默认值= 0。

  • l: It is an optional parameter, which represents the number of lines one week would use in the resulting string, default value = 0.

    l :这是一个可选参数,表示一周后将在结果字符串中使用的行数,默认值为0。

Return value:

返回值:

The return type of this method is <class 'NoneType'>, it prints the corresponding calendar of the given year's month.

此方法的返回类型为<class'NoneType'> ,它打印给定年份月份的相应日历。

Example:

例:

# Python program to illustrate the # use of prmonth() method# import classimport calendar# creating a TextCalendar instancecal = calendar.TextCalendar()year = 2019month = 12print("Printing December 2019 calendar with default paramters, w = 0, l = 0")cal.prmonth(year, month)print()# Setting width=3 cal = calendar.TextCalendar()year = 1919month = 1print("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 = 1999month = 11print("Printing November 1999 calendar with w = 3, l = 2")cal.prmonth(year, month, 3, 2)print()# Changing the firstweekdaycal = calendar.TextCalendar(firstweekday = 4)# First column will be Fridayyear = 2005month = 5print("Printing May 2005 calendar with  w = 3, l = 1 and first column starting with Friday")cal.prmonth(year, month, 3, 1)print()

Output

输出量

Printing December 2019 calendar with default paramters, w = 0, l = 0   December 2019Mo Tu We Th Fr Sa Su                   1 2  3  4  5  6  7  8 9 10 11 12 13 14 1516 17 18 19 20 21 2223 24 25 26 27 28 2930 31Printing January 1919 calendar with w = 3        January 1919Mon 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  31Printing November 1999 calendar with w = 3, l = 2       November 1999Mon 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  30Printing May 2005 calendar with  w = 3, l = 1 and first column starting with Friday          May 2005Fri 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 示例

转载地址:http://dwvzd.baihongyu.com/

你可能感兴趣的文章
优雅的程序员
查看>>
oracle之三 自动任务调度
查看>>
Android dex分包方案
查看>>
ThreadLocal为什么要用WeakReference
查看>>
删除本地文件
查看>>
FOC实现概述
查看>>
base64编码的图片字节流存入html页面中的显示
查看>>
这个大学时代的博客不在维护了,请移步到我的新博客
查看>>
GUI学习之二十一——QSlider、QScroll、QDial学习总结
查看>>
nginx反向代理docker registry报”blob upload unknown"解决办法
查看>>
gethostbyname与sockaddr_in的完美组合
查看>>
kibana的query string syntax 笔记
查看>>
旋转变换(一)旋转矩阵
查看>>
thinkphp3.2.3 bug集锦
查看>>
[BZOJ 4010] 菜肴制作
查看>>
C# 创建 读取 更新 XML文件
查看>>
KD树
查看>>
VsVim - Shortcut Key (快捷键)
查看>>
C++练习 | 模板与泛式编程练习(1)
查看>>
HDU5447 Good Numbers
查看>>