python日历模块_Python日历模块| setfirstweekday()方法与示例
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中日歷模塊的內(nèi)置方法。 它適用于簡單的文本日歷,并設(shè)置從一周開始的第一個工作日。 在這里,星期一是0,遞增1直到星期日是6。我們還可以使用calendar.day_name ,其中calendar.MONDAY為0, calendar.SUNDAY為6。
Module:
模塊:
import calendarSyntax:
句法:
setfirstweekday(weekday)Parameter(s):
參數(shù):
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 :這是一個可選參數(shù),代表周一的日期,其中MONDAY為0,SUNDAY為6。默認(rèn)值為0。
Return value:
返回值:
The return type of this method is <class 'NoneType'>, it sets an iterator for the week day numbers.
此方法的返回類型為<class'NoneType'> ,它為工作日編號設(shè)置迭代器。
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 SUNDAYOutput
輸出量
NoneNone6翻譯自: https://www.includehelp.com/python/calendar-setfirstweekday-method-with-example.aspx
python日歷模塊
總結(jié)
以上是生活随笔為你收集整理的python日历模块_Python日历模块| setfirstweekday()方法与示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java LocalDateTime类|
- 下一篇: synchronized 加锁 this