博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 示例_Python日历类| itermonthdates()方法与示例
阅读量:2544 次
发布时间:2019-05-11

本文共 2141 字,大约阅读时间需要 7 分钟。

python 示例

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

Calendar.itermonthdates() 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(1–12) in the given year. The iterator will return all days (as datetime.date objects) for the month and all days before the start of the month or after the end of the month that are required to get a complete week.

Calendar.itermonthdates()方法是Python中Calendar模块的Calendar类的内置方法。 它使用此类的实例,并返回给定年份中给定月(1–12)的迭代器。 迭代器将返回该月的所有天(作为datetime.date对象)以及该月初或该月末之后整整一周所需的所有天。

Module:

模块:

import calendar

Class:

类:

from calendar import Calendar

Syntax:

句法:

itermonthdates(year, month)

Parameter(s):

参数:

  • year: represents the year of the calendar

    年 :代表日历的年份

  • month: represents month of the calendar

    month :代表日历的月份

Return value:

返回值:

The function returns an iterator for the given month of the given year.

该函数返回给定年份中给定月份的迭代器。

Example:

例:

# Python program to illustrate the # use of itermonthdates() method# import classimport calendar# Creating Calendar Instancecal = calendar.Calendar()year = 2020month = 2# Complete weeks will be printedfor i in cal.itermonthdates(year, month):    print(i)print()# Setting firstweekday value to 3cal = calendar.Calendar(firstweekday = 3)year = 2016month = 2for i in cal.itermonthdates(year, month):    print(i)

Output

输出量

2020-01-272020-01-282020-01-292020-01-302020-01-312020-02-012020-02-022020-02-032020-02-042020-02-052020-02-062020-02-072020-02-082020-02-092020-02-102020-02-112020-02-122020-02-132020-02-142020-02-152020-02-162020-02-172020-02-182020-02-192020-02-202020-02-212020-02-222020-02-232020-02-242020-02-252020-02-262020-02-272020-02-282020-02-292020-03-012016-01-282016-01-292016-01-302016-01-312016-02-012016-02-022016-02-032016-02-042016-02-052016-02-062016-02-072016-02-082016-02-092016-02-102016-02-112016-02-122016-02-132016-02-142016-02-152016-02-162016-02-172016-02-182016-02-192016-02-202016-02-212016-02-222016-02-232016-02-242016-02-252016-02-262016-02-272016-02-282016-02-292016-03-012016-03-02

Reference:

参考:

翻译自:

python 示例

转载地址:http://pzvzd.baihongyu.com/

你可能感兴趣的文章
vue-cli3创建项目时报错
查看>>
输入1-53周,输出1-53周的开始时间和结束时间
查看>>
实验二
查看>>
shell——按指定列排序
查看>>
crash 收集
查看>>
507 LOJ 「LibreOJ NOI Round #1」接竹竿
查看>>
UI基础--烟花动画
查看>>
2018. 2.4 Java中集合嵌套集合的练习
查看>>
精通ASP.NET Web程序测试
查看>>
vue 根据不同属性 设置背景
查看>>
51Nod1601 完全图的最小生成树计数 Trie Prufer编码
查看>>
Codeforces 1110D. Jongmah 动态规划
查看>>
android驱动在win10系统上安装的心酸历程
查看>>
优雅的程序员
查看>>
oracle之三 自动任务调度
查看>>
Android dex分包方案
查看>>
ThreadLocal为什么要用WeakReference
查看>>
删除本地文件
查看>>
FOC实现概述
查看>>
base64编码的图片字节流存入html页面中的显示
查看>>