Python calendar.firstweekday() 方法
firstweekday() 方法是 Python 中日历模块的内置方法。它适用于简单的文本日历,并返回每周开始的工作日的当前设置。
模块:
import calendar
用法:
firstweekday()
参数:
- None
返回值:
该函数返回一个从 0 到 6 的数字,其中星期一表示 0,依此类推。
例:
# 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())
输出
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
相关用法
- Python calendar weekday()用法及代码示例
- Python calendar isleap()用法及代码示例
- Python calendar setfirstweekday()用法及代码示例
- Python calendar leapdays()用法及代码示例
- Python calendar weekheader()用法及代码示例
- Python calendar calendar()用法及代码示例
- Python calendar monthcalendar()用法及代码示例
- Python calendar month()用法及代码示例
- Python calendar monthrange()用法及代码示例
- Python calendar prmonth()用法及代码示例
- Python calendar prcal()用法及代码示例
- Python callable()用法及代码示例
- Python string capwords()用法及代码示例
- Python Functools cached_property()用法及代码示例
- Python cmath.isclose()用法及代码示例
- Python cmp()用法及代码示例
- Python compile()用法及代码示例
- Python cmath.log10()用法及代码示例
- Python cmath.asinh()用法及代码示例
- Python OpenCV cv2.rectangle()用法及代码示例
注:本文由纯净天空筛选整理自 Python calendar Module | firstweekday() Method with Example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。