Python日历模块| weekheader()方法与示例
Python calendar.weekheader()方法 (Python calendar.weekheader() Method)
weekheader() method is an inbuilt method of the calendar module in Python. It works on simple text calendars and returns a header containing the abbreviated names of the weekday.
weekheader()方法是Python中日歷模塊的內置方法。 它適用于簡單的文本日歷,并返回包含工作日縮寫名稱的標頭。
Module:
模塊:
import calendarSyntax:
句法:
weekheader(n)Parameter(s):
參數:
n: It is a required parameter, which represents the width in characters for one weekday.
n :這是必填參數,代表一個工作日的字符寬度。
Return value:
返回值:
The return type of this method is <class 'str'> (a string), it returns a header containing abbreviated weekday names.
此方法的返回類型為<class'str'> (字符串),它返回包含縮寫的工作日名稱的標頭。
Example:
例:
## Python program to illustrate the ## use of weekheader() method# importing calendar module import calendar n = 1 print("When width in character for one weekday = 1") print(calendar.weekheader(n)) print()n = 3 print("When width in character for one weekday = 3") print(calendar.weekheader(n)) print()n = 5 print("When width in character for one weekday = 5") print(calendar.weekheader(n)) print()n = 10 print("When width in character for one weekday = 10") print(calendar.weekheader(n)) print()n = 15 print("When width in character for one weekday = 15") print(calendar.weekheader(n))Output
輸出量
When width in character for one weekday = 1 M T W T F S SWhen width in character for one weekday = 3 Mon Tue Wed Thu Fri Sat SunWhen width in character for one weekday = 5Mon Tue Wed Thu Fri Sat Sun When width in character for one weekday = 10Monday Tuesday Wednesday Thursday Friday Saturday Sunday When width in character for one weekday = 15Monday Tuesday Wednesday Thursday Friday Saturday Sunday翻譯自: https://www.includehelp.com/python/calendar-weekheader-method-with-example.aspx
總結
以上是生活随笔為你收集整理的Python日历模块| weekheader()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 再见Postman,这款API神器更好用
- 下一篇: Java PipedOutputStre