python日历模块_Python日历模块| firstweekday()方法与示例

python日历模块

Python calendar.firstweekday()方法 (Python calendar.firstweekday() Method)

firstweekday() method is an inbuilt method of the calendar module in Python. It works on simple text calendars and returns the current setting for the weekday to start each week.

firstweekday()方法是Python中日历模块的内置方法。 它适用于简单的文本日历,并返回每个星期开始的工作日的当前设置。

Module:

模块:

    import calendar

Syntax:

句法:

    firstweekday()

Parameter(s):

参数:

  • None

    没有

Return value:

返回值:

The function returns a number from 0 to 6 where Monday indicates 0 and so on.

该函数返回从0到6的数字,其中星期一表示0,依此类推。

Example:

例:

# Python program to illustrate the 
# use of firstweekday() method
  
# importing calendar module 
import calendar 
  
# using setfirstweekday() function 
calendar.setfirstweekday(2) 
print(calendar.firstweekday())
print()

val = calendar.setfirstweekday(calendar.FRIDAY)
# sets the value to 4 which is the weekday value for FRIDAY
print(calendar.firstweekday())
# prints 4
print()

# Printing 3rd month of 2020
calendar.setfirstweekday(calendar.THURSDAY)
print("Third month of 2020:")
calendar.prmonth(2020, 3, 2, 1)
# It starts displaying the calendar from THURSDAY
print("The first weekday of the third month of 2020 is:", calendar.firstweekday())

Output

输出量

2

4

Third month of 2020:
     March 2020
Th Fr Sa Su Mo Tu We
          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
The first weekday of the third month of 2020 i
s: 3


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

python日历模块

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值