python日历模块
Python calendar.setfirstweekday()方法 (Python calendar.setfirstweekday() Method)
setfirstweekday() method is an inbuilt method of the calendar module in Python. It works on simple text calendars and sets the first weekday from when the week should start. Here, Monday is 0, incrementing by 1 till Sunday, which is 6. We can also use calendar.day_name where calendar.MONDAY is 0 and calendar.SUNDAY is 6.
setfirstweekday()方法是Python中日历模块的内置方法。 它适用于简单的文本日历,并设置从一周开始的第一个工作日。 在这里,星期一是0,递增1直到星期日是6。我们还可以使用calendar.day_name ,其中calendar.MONDAY为0, calendar.SUNDAY为6。
Module:
模块:
import calendar
Syntax:
句法:
setfirstweekday(weekday)
Parameter(s):
参数:
weekday: It is an optional parameter, which represents the weekday number where MONDAY is 0 and SUNDAY is 6. Its default value is 0.
weekday :这是一个可选参数,代表周一的日期,其中MONDAY为0,SUNDAY为6。默认值为0。
Return value:
返回值:
The return type of this method is <class 'NoneType'>, it sets an iterator for the week day numbers.
此方法的返回类型为<class'NoneType'> ,它为工作日编号设置迭代器。
Example:
例:
# Python program to illustrate the
# use of setfirstweekday() method
# importing calendar module
import calendar
# using setfirstweekday() function
val = calendar.setfirstweekday(2)
# returns None
print(val)
# The function does not return anything,
# it only sets the value
print()
val = calendar.setfirstweekday(calendar.WEDNESDAY)
# sets the value to 2 which is the weekday value
# for WEDNESDAY
print(val)
print()
# Using firstweekday() method to check what was
# the day sets
calendar.setfirstweekday(calendar.SUNDAY)
print(calendar.firstweekday())
# Prints 6 which is the weekday value for SUNDAY
Output
输出量
None
None
6
翻译自: https://www.includehelp.com/python/calendar-setfirstweekday-method-with-example.aspx
python日历模块