python 示例

编程入门 行业动态 更新时间:2024-10-17 20:23:03

python <a href=https://www.elefans.com/category/jswz/34/1770116.html style=示例"/>

python 示例

python 示例

Python Calendar.itermonthdays4()方法 (Python Calendar.itermonthdays4() Method)

Calendar.itermonthdays4() method is an inbuilt method of the Calendar class of calendar module in Python. It uses an instance of this class and returns an iterator for the given month in the given year. The month consists of full weeks, ie, each week has full 7 values even if the value is outside of the month. An entry in a week is given by a tuple consisting of a year, a month, a day of the month and the weekday number, ie, weekday on that day.

Calendar.itermonthdays4()方法是Python中Calendar模块的Calendar类的内置方法。 它使用此类的实例,并返回给定年份中给定月份的迭代器。 该月由整周组成,即,即使该值在该月之外,每个星期也有完整的7个值。 一个星期中的条目由一个元组给出,该元组包括一年,一个月,一个月中的某天以及工作日数,即该天的工作日。

The method is available from version 3.7

该方法从3.7版开始可用

Module:

模块:

    import calendar

Class:

类:

    from calendar import Calendar

Syntax:

句法:

    itermonthdays4(year, month)

Parameter(s):

参数:

  • year: It is a required parameter, which specifies the year of the calendar.

    year :这是必填参数,用于指定日历的年份。

  • month: It is a required parameter, which specifies the month of the calendar.

    month :这是必填参数,用于指定日历的月份。

Return value:

返回值:

The return type of this method is <class 'generator'>, it returns an iterator for the month where each tuple tells you the complete day and the date of that month.

此方法的返回类型为<class'generator'> ,它返回该月的迭代器,其中每个元组告诉您该月的完整日期和日期。

Example:

例:

# Python program to illustrate the 
# use of itermonthdays4() method# import class
import calendar# Creating Calendar Instance
cal = calendar.Calendar()
year = 2017
month = 11for i in cal.itermonthdays4(year, month):print(i)# tuple value is: year,month,day, weekday number
# Note: iterator always start from firstweekday number
print()
print()# set the firstweekday to 3
cal = calendar.Calendar(firstweekday = 3)
year = 1994
month = 7for i in cal.itermonthdays4(year, month):print(i)
print()
print()

Output

输出量

(2017, 10, 30, 0)
(2017, 10, 31, 1)
(2017, 11, 1, 2)
(2017, 11, 2, 3)
(2017, 11, 3, 4)
(2017, 11, 4, 5)
(2017, 11, 5, 6)
(2017, 11, 6, 0)
(2017, 11, 7, 1)
(2017, 11, 8, 2)
(2017, 11, 9, 3)
(2017, 11, 10, 4)
(2017, 11, 11, 5)
(2017, 11, 12, 6)
(2017, 11, 13, 0)
(2017, 11, 14, 1)
(2017, 11, 15, 2)
(2017, 11, 16, 3)
(2017, 11, 17, 4)
(2017, 11, 18, 5)
(2017, 11, 19, 6)
(2017, 11, 20, 0)
(2017, 11, 21, 1)
(2017, 11, 22, 2)
(2017, 11, 23, 3)
(2017, 11, 24, 4)
(2017, 11, 25, 5)
(2017, 11, 26, 6)
(2017, 11, 27, 0)
(2017, 11, 28, 1)
(2017, 11, 29, 2)
(2017, 11, 30, 3)
(2017, 12, 1, 4)
(2017, 12, 2, 5)
(2017, 12, 3, 6)(1994, 6, 30, 3)
(1994, 7, 1, 4)
(1994, 7, 2, 5)
(1994, 7, 3, 6)
(1994, 7, 4, 0)
(1994, 7, 5, 1)
(1994, 7, 6, 2)
(1994, 7, 7, 3)
(1994, 7, 8, 4)
(1994, 7, 9, 5)
(1994, 7, 10, 6)
(1994, 7, 11, 0)
(1994, 7, 12, 1)
(1994, 7, 13, 2)
(1994, 7, 14, 3)
(1994, 7, 15, 4)
(1994, 7, 16, 5)
(1994, 7, 17, 6)
(1994, 7, 18, 0)
(1994, 7, 19, 1)
(1994, 7, 20, 2)
(1994, 7, 21, 3)
(1994, 7, 22, 4)
(1994, 7, 23, 5)
(1994, 7, 24, 6)
(1994, 7, 25, 0)
(1994, 7, 26, 1)
(1994, 7, 27, 2)
(1994, 7, 28, 3)
(1994, 7, 29, 4)
(1994, 7, 30, 5)
(1994, 7, 31, 6)
(1994, 8, 1, 0)
(1994, 8, 2, 1)
(1994, 8, 3, 2)

翻译自: .aspx

python 示例

更多推荐

python 示例

本文发布于:2024-03-13 15:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1734292.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:示例   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!