python 示例_Python TextCalendar類別| pryear()方法與示例

python 示例

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

pryear() 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 calendar for an entire year Also, there is no need for a "print" operation to execute this.

pryear()方法是Python中日歷模塊的TextCalendar類的內置方法。 它適用于文本日歷。 它使用TextCalendar類的實例并打印整年的日歷。此外,不需要執行“打印”操作即可執行此操作。

Module:

模塊:

    import calendar

Class:

類:

    from calendar import TextCalendar

Syntax:

句法:

    pryear(year, w=2, l=1, c=6, m=3)

Parameter(s):

參數:

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

    year :這是必填參數,用于指定日歷的年份。

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

    w :這是一個可選參數,用于指定日期列的寬度; 默認值= 2。

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

    l :這是一個可選參數,代表一周中將在結果字符串中使用的行數; 默認值= 1。

  • c: It is an optional parameter, which specifies the number of spaces between month columns; default value = 6.

    c :這是一個可選參數,用于指定月份列之間的空格數; 默認值= 6

  • m: It is an optional parameter, which represents the number of column of months in a row in the calendar; default value = 3.

    m :這是一個可選參數,代表日歷中一行中月份的列數; 默認值= 3。

Return value:

返回值:

The return type of this method is <class 'NoneType'>, it prints an m-column calendar for an entire year.

此方法的返回類型為<class'NoneType'> ,它將打印整個一年的m列日歷。

Example:

例:

# Python program to illustrate the 
# use of pryear() method
# import class
import calendar
# creating a TextCalendar instance
cal = calendar.TextCalendar()
year = 2019
print("2019 calendar with default values w=2, l=1, c=6, m=3")
cal.pryear(year)
print()
# Setting c =3, l=2,w=3
cal = calendar.TextCalendar()
year = 1919
print("1919 calendar with w=3, l=2, c=3")
# Parameters missing have default values
cal.pryear(year, 3, 2, 3)
print()
# Setting m=2
# Number of months in a row will be 2
cal = calendar.TextCalendar()
year = 1999
print("1999 calendar with number of month columns in a row=2")
cal.pryear(year, m=2)
print()

Output

輸出量

2019 calendar with default values w=2, l=1, c=6, m=3
2019
January                   February                   March
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3  4  5  6                   1  2  3                   1  2  3
7  8  9 10 11 12 13       4  5  6  7  8  9 10       4  5  6  7  8  9 10
14 15 16 17 18 19 20      11 12 13 14 15 16 17      11 12 13 14 15 16 17
21 22 23 24 25 26 27      18 19 20 21 22 23 24      18 19 20 21 22 23 24
28 29 30 31               25 26 27 28               25 26 27 28 29 30 31
April                      May                       June
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3  4  5  6  7             1  2  3  4  5                      1  2
8  9 10 11 12 13 14       6  7  8  9 10 11 12       3  4  5  6  7  8  9
15 16 17 18 19 20 21      13 14 15 16 17 18 19      10 11 12 13 14 15 16
22 23 24 25 26 27 28      20 21 22 23 24 25 26      17 18 19 20 21 22 23
29 30                     27 28 29 30 31            24 25 26 27 28 29 30
July                     August                  September
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3  4  5  6  7                1  2  3  4                         1
8  9 10 11 12 13 14       5  6  7  8  9 10 11       2  3  4  5  6  7  8
15 16 17 18 19 20 21      12 13 14 15 16 17 18       9 10 11 12 13 14 15
22 23 24 25 26 27 28      19 20 21 22 23 24 25      16 17 18 19 20 21 22
29 30 31                  26 27 28 29 30 31         23 24 25 26 27 28 29
30
October                   November                  December
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3  4  5  6                   1  2  3                         1
7  8  9 10 11 12 13       4  5  6  7  8  9 10       2  3  4  5  6  7  8
14 15 16 17 18 19 20      11 12 13 14 15 16 17       9 10 11 12 13 14 15
21 22 23 24 25 26 27      18 19 20 21 22 23 24      16 17 18 19 20 21 22
28 29 30 31               25 26 27 28 29 30         23 24 25 26 27 28 29
30 31
1919 calendar with w=3, l=2, c=3
1919
January                       February                       March
Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
1   2   3   4   5                         1   2                         1   2
6   7   8   9  10  11  12     3   4   5   6   7   8   9     3   4   5   6   7   8   9
13  14  15  16  17  18  19    10  11  12  13  14  15  16    10  11  12  13  14  15  16
20  21  22  23  24  25  26    17  18  19  20  21  22  23    17  18  19  20  21  22  23
27  28  29  30  31            24  25  26  27  28            24  25  26  27  28  29  30
31
April                          May                           June
Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
1   2   3   4   5   6                 1   2   3   4                             1
7   8   9  10  11  12  13     5   6   7   8   9  10  11     2   3   4   5   6   7   8
14  15  16  17  18  19  20    12  13  14  15  16  17  18     9  10  11  12  13  14  15
21  22  23  24  25  26  27    19  20  21  22  23  24  25    16  17  18  19  20  21  22
28  29  30                    26  27  28  29  30  31        23  24  25  26  27  28  29
30
July                         August                      September
Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
1   2   3   4   5   6                     1   2   3     1   2   3   4   5   6   7
7   8   9  10  11  12  13     4   5   6   7   8   9  10     8   9  10  11  12  13  14
14  15  16  17  18  19  20    11  12  13  14  15  16  17    15  16  17  18  19  20  21
21  22  23  24  25  26  27    18  19  20  21  22  23  24    22  23  24  25  26  27  28
28  29  30  31                25  26  27  28  29  30  31    29  30
October                       November                      December
Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun   Mon Tue Wed Thu Fri Sat Sun
1   2   3   4   5                         1   2     1   2   3   4   5   6   7
6   7   8   9  10  11  12     3   4   5   6   7   8   9     8   9  10  11  12  13  14
13  14  15  16  17  18  19    10  11  12  13  14  15  16    15  16  17  18  19  20  21
20  21  22  23  24  25  26    17  18  19  20  21  22  23    22  23  24  25  26  27  28
27  28  29  30  31            24  25  26  27  28  29  30    29  30  31
1999 calendar with number of month columns in a row=2
1999
January                   February
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3       1  2  3  4  5  6  7
4  5  6  7  8  9 10       8  9 10 11 12 13 14
11 12 13 14 15 16 17      15 16 17 18 19 20 21
18 19 20 21 22 23 24      22 23 24 25 26 27 28
25 26 27 28 29 30 31
March                     April
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3  4  5  6  7                1  2  3  4
8  9 10 11 12 13 14       5  6  7  8  9 10 11
15 16 17 18 19 20 21      12 13 14 15 16 17 18
22 23 24 25 26 27 28      19 20 21 22 23 24 25
29 30 31                  26 27 28 29 30
May                       June
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2          1  2  3  4  5  6
3  4  5  6  7  8  9       7  8  9 10 11 12 13
10 11 12 13 14 15 16      14 15 16 17 18 19 20
17 18 19 20 21 22 23      21 22 23 24 25 26 27
24 25 26 27 28 29 30      28 29 30
31
July                     August
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3  4                         1
5  6  7  8  9 10 11       2  3  4  5  6  7  8
12 13 14 15 16 17 18       9 10 11 12 13 14 15
19 20 21 22 23 24 25      16 17 18 19 20 21 22
26 27 28 29 30 31         23 24 25 26 27 28 29
30 31
September                  October
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3  4  5                   1  2  3
6  7  8  9 10 11 12       4  5  6  7  8  9 10
13 14 15 16 17 18 19      11 12 13 14 15 16 17
20 21 22 23 24 25 26      18 19 20 21 22 23 24
27 28 29 30               25 26 27 28 29 30 31
November                  December
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
1  2  3  4  5  6  7             1  2  3  4  5
8  9 10 11 12 13 14       6  7  8  9 10 11 12
15 16 17 18 19 20 21      13 14 15 16 17 18 19
22 23 24 25 26 27 28      20 21 22 23 24 25 26
29 30                     27 28 29 30 31

翻譯自: https://www.includehelp.com/python/textcalendar-pryear-method-with-example.aspx

python 示例

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541930.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541930.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541930.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Spring實戰——通過Java代碼裝配bean

上篇說的是無需半行xml配置完成bean的自動化注入。這篇仍然不要任何xml配置&#xff0c;通過Java代碼也能達到同樣的效果。 這么說&#xff0c;是要把上篇的料拿出來再煮一遍&#xff1f; 當然不是&#xff0c;上篇我們幾乎都在用注解的方式如ComponentScan Component等就完成了…

java 謂詞_java8-謂詞(predicate)

傳遞代碼我們首先看一個例子&#xff0c;假設你有一個 Apple 類&#xff0c;它有一個getColor方法&#xff0c;還有一個變量inventory保存著一個Apples的列表。你可能想要選出所有的綠蘋果&#xff0c;并返回一個列表。通常我們用篩選(filter)一詞來表達這個概念。在 Java 8之前…

getlong_Java LocalDateTime類| 帶示例的getLong()方法

getlongLocalDateTime類的getLong()方法 (LocalDateTime Class getLong() method) getLong() method is available in java.time package. getLong()方法在java.time包中可用。 getLong() method is used to get the value as long for the given temporal field from this dat…

java.io和util的區別_Java NIO與IO的區別和比較

Java NIO與IO的區別和比較導讀J2SE1.4以上版本中發布了全新的I/O類庫。本文將通過一些實例來簡單介紹NIO庫提供的一些新特性&#xff1a;非阻塞I/O&#xff0c;字符轉換&#xff0c;緩沖以及通道。一. 介紹NIONIO包(java.nio.*)引入了四個關鍵的抽象數據類型&#xff0c;它們共…

Java LocalDate類| isSupported()方法與示例

LocalDate類isSupported()方法 (LocalDate Class isSupported() method) Syntax: 句法&#xff1a; public boolean isSupported (TemporalField t_field);public boolean isSupported (TemporalUnit t_unit);isSupported() method is available in java.time package. isSupp…

區塊鏈+稅務的思考

2016年&#xff0c;區塊鏈技術火了&#xff01;各大金融公司、互聯網巨頭都競相參加到區塊鏈技術的研究中。我們公司的業務是稅務的信息化領域&#xff0c;也希望通過區塊鏈技術的應用&#xff0c;來提升為財稅領域的服務。 區塊鏈技術優缺點總結 下圖是對區塊鏈技術的一些特點…

java hasset 順序_java集合排序問題

List: 元素是有序的&#xff0c;元素可以重復&#xff0c;因為該集合體系有索引(腳標)常用的子類對象&#xff1a;1————ArrayList 底層的數據結構是使用的數組結構特點&#xff1a;查詢速度快&#xff0c;但是增刪比較慢2————LinkedList底層的數據結構使用的是鏈表結構…

如何使用JavaScript刪除CSS屬性?

In this article, well see how we can remove a CSS property from a certain element using JavaScript? We can remove only those properties that we assign ourselves and the pre-default ones cannot be removed by this method. 在本文中&#xff0c;我們將看到如何使…

Django 緩存系統

Django 是動態網站&#xff0c;一般來說需要實時地生成訪問的網頁&#xff0c;展示給訪問者&#xff0c;這樣&#xff0c;內容可以隨時變化&#xff0c;但是從數據庫讀多次把所需要的數據取出來&#xff0c;要比從內存或者硬盤等一次讀出來 付出的成本大很多。 緩存系統工作原理…

java web截屏_java_WebDriver中實現對特定的Web區域截圖方法,用過 WebDriver 的同學都知道,We - phpStudy...

WebDriver中實現對特定的Web區域截圖方法用過 WebDriver 的同學都知道&#xff0c;WebDriver 可以對瀏覽器中的頁面進行截圖。例如&#xff1a;public byte[] takeScreenshot() throws IOException {TakesScreenshot takesScreenshot (TakesScreenshot) driver;return takesSc…

c語言 關鍵字const_C ++ const關鍵字| 查找輸出程序| 套裝1

c語言 關鍵字constProgram 1: 程序1&#xff1a; #include <iostream>using namespace std;void fun(int& A) const{A 10;}int main(){int X 0;fun(X);cout << X;return 0;}Output: 輸出&#xff1a; [Error] non-member function void fun(int) cannot ha…

【喜報】JEEWX榮獲“2016 年度碼云新增熱門開源軟件排行榜”第一名!

為什么80%的碼農都做不了架構師&#xff1f;>>> 2016 年度碼云新增項目排行榜 TOP 50 正式出爐&#xff01;根據 2016 年在碼云上新增開源項目的 Watch、Star、Fork 數量以及其他角度的統計&#xff0c;JEEWX捷微管家榮獲“2016 年度碼云新增熱門開源軟件排行榜”第…

java 二叉樹特點_瘋狂java筆記之樹和二叉樹

樹的概述樹是一種非常常用的數據結構&#xff0c;樹與前面介紹的線性表&#xff0c;棧&#xff0c;隊列等線性結構不同&#xff0c;樹是一種非線性結構1.樹的定義和基本術語計算機世界里的樹&#xff0c;是從自然界中實際的樹抽象而來的&#xff0c;它指的是N個有父子關系的節點…

編輯距離 dp_使用動態編程(DP)編輯距離

編輯距離 dpProblem: You are given two strings s1 and s2 of length M and N respectively. You can perform following operations on the string. 問題&#xff1a;給您兩個長度分別為M和N的字符串s1和s2 。 您可以對字符串執行以下操作。 Insert a character at any posi…

tomcat +apache 配置集群

2019獨角獸企業重金招聘Python工程師標準>>> APACHE2.2.25TOMCAT6.0.37配置負載均衡 目標: 使用 apache 和 tomcat 配置一個可以應用的 web 網站&#xff0c;要達到以下要求&#xff1a; 1. Apache 做為 HttpServer &#xff0c;后面連接多個 tomcat 應用實例&…

java雙緩存機制_詳解JVM類加載機制及類緩存問題的處理方法

前言大家應該都知道&#xff0c;當一個Java項目啟動的時候&#xff0c;JVM會找到main方法&#xff0c;根據對象之間的調用來對class文件和所引用的jar包中的class文件進行加載(其步驟分為加載、驗證、準備、解析、初始化、使用和卸載)&#xff0c;方法區中開辟內存來存儲類的運…

oracle中dbms_并發和由于DBMS中的并發導致的問題

oracle中dbms并發 (Concurrency) The ability of a database system which handles simultaneously or a number of transactions by interleaving parts of the actions or the overlapping this is called concurrency of the system. 數據庫系統通過交織部分操作或重疊操作來…

什么是mvc?

什么是MVCMVC 是一種設計模式&#xff0c;它將應用劃分為3 個部分&#xff1a;數據&#xff08;模型&#xff09;、展現層&#xff08;視圖&#xff09;和用戶交互層&#xff08;控制器&#xff09;。換句話說&#xff0c;一個事件的發生是這樣的過程&#xff1a;1&#xff0e;…

mysql的安裝和基本命令_MySQL安裝以及簡單命令用法

MYSQL:關系型數據庫存儲引擎:負責將邏輯層的概念轉化為物理層機制&#xff0c;在物理層完成物理機制。支持事務&#xff1a;transaction必須滿足的條件&#xff1a;ACID(一致性,持久性,原子性,隔離性)鎖&#xff1a;并發訪問隨機訪問&#xff1a;數據在磁盤上是隨機存儲的安裝&…