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 calendar

Syntax:

句法:

    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 S

When width in character for one weekday = 3
Mon Tue Wed Thu Fri Sat Sun

When width in character for one weekday = 5
 Mon   Tue   Wed   Thu   Fri   Sat   Sun 

When width in character for one weekday = 10
  Monday    Tuesday   Wednesday   Thursday    Friday    Saturday    
  Sunday  

When width in character for one weekday = 15
     Monday         Tuesday        Wednesday        Thursday         
     Friday         Saturday         Sunday 


翻译自: https://www.includehelp.com/python/calendar-weekheader-method-with-example.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值