Python日历类| 带示例的iterweekdays()方法

news/2024/6/18 23:54:30 标签: python, django, 深度学习, ios

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

Calendar.iterweekdays() 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 weekday numbers that are used for one week. The first number that the iterator returns is the first weekday set for that instance. By default, the first-weekday set is 0 which is Monday.

Calendar.iterweekdays()方法是Python中Calendar模块的Calendar类的内置方法。 它使用此类的实例,并为一个星期使用的星期几返回一个迭代器。 迭代器返回的第一个数字是该实例设置的第一个工作日。 默认情况下,第一个工作日设置为0,即星期一。

Module:

模块:

    import calendar

Class:

类:

    from calendar import Calendar

Syntax:

句法:

    iterweekdays()

Parameter(s):

参数:

  • None

    没有

Return value:

返回值:

The return type of this method is <class 'generator'>, it returns an iterator for the weekday numbers giving 7 weekday numbers starting from that iterator.

此方法的返回类型为<class'generator'> ,它返回工作日编号的迭代器,从该迭代器开始提供7个工作日编号。

Example:

例:

# Python program to illustrate the 
# use of iterweekdays() method

# import module
import calendar

# Creating Calendar instance
cal = calendar.Calendar()
print("Iterating with first weekday as 0, ie, Monday")
for i in cal.iterweekdays():
    print(i)
print()

# Changing firstweekday for the Calendar
cal  = calendar.Calendar(firstweekday = 3)
# iterator starts with 3
print("Iterating with first weekday as 3, ie, Thursday")
for i in cal.iterweekdays():
    print(i)
print()

Output

输出量

Iterating with first weekday as 0, ie, Monday
0
1
2
3
4
5
6

Iterating with first weekday as 3, ie, Thursday
3
4
5
6
0
1
2


翻译自: https://www.includehelp.com/python/calendar-calendar-iterweekdays-method-with-example.aspx


http://www.niftyadmin.cn/n/1255950.html

相关文章

webapi 使用Autofac 开发经历

2018/4/6 号 早上五点..被手机震动吵醒。 之后直接打开电脑&#xff0c;打算再加强下我自己的webapi这套东西。 虽然三年的工作经验接触了N多框架和各种风格的开发方式&#xff0c;但是让我自己来搞一套实在不会搞&#xff0c;学基础的时候学过&#xff0c;但也早已忘了&#x…

c# uri.host_C#| Uri.IsWellFormedOriginalString()方法与示例

c# uri.hostUri.IsWellFormedOriginalString()方法 (Uri.IsWellFormedOriginalString() Method) Uri.IsWellFormedOriginalString() method is used to check whether given Uri is well-formed or not, if Uri is well-formed, the method returns true otherwise it returns …

js数组方法解析

js 数组有很多方法&#xff0c;其中有的常用&#xff0c;有的不常用&#xff0c;归纳几个常用的方法&#xff0c;做个总结&#xff1a; 1. 转换方法&#xff1a; 1.1 valueOf()&#xff1a;调用这个方法会返回数组本身 1 <script> 2 var arr [blue, red, yello…

Convolution theorem in finite domain

1、https://math.stackexchange.com/questions/2305411/convolution-theorem-in-finite-domain2、https://math.stackexchange.com/questions/1866465/is-it-possible-to-use-the-convolution-theorem-on-a-finite-interval-integral-l3、https://math.stackexchange.com/quest…

java math log_Java Math类静态double log1p(double d)及其示例

java math log数学类静态double log1p(double d) (Math Class static double log1p(double d) ) This method is available in java.lang package. 此方法在java.lang包中可用。 This method is used to return (the logarithm of the sum of the given argument and 1 like lo…

【转】Python3学习笔记(urllib模块的使用)

原文地址&#xff1a;https://www.cnblogs.com/Lands-ljk/p/5447127.html 1.基本方法 urllib.request.urlopen(url, dataNone, [timeout, ]*, cafileNone, capathNone, cadefaultFalse, contextNone) - url: 需要打开的网址 - data&#xff1a;Post提交的数据…

python 打印文件名_Python | 打印文件内容以及文件名

python 打印文件名打印文件名 (Printing file name ) To print the filename, we use "file_object.name". 要打印文件名&#xff0c;我们使用“ file_object.name” 。 打印文件内容 (Printing files content) To print the content of a file, we use "read(…