日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python 示例_带有示例的Python date isocalendar()方法

發布時間:2023/12/1 python 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 示例_带有示例的Python date isocalendar()方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

python 示例

Python date.isocalendar()方法 (Python date.isocalendar() Method)

date.isocalendar() method is used to manipulate objects of date class of module datetime.

date.isocalendar()方法用于操作模塊datetime的日期類的對象。

It uses a date class object and returns a 3-tuple (ISO year, ISO week number, ISO weekday).

它使用日期類對象并返回一個三元組(ISO年,ISO周號,ISO周日)。

Most of the date and time calendar follow the Gregorian calendar. The ISO calendar is a widely used variant of the Gregorian one. The ISO year consists of 52 or 53 full weeks, and where a week starts on a Monday and ends on a Sunday. The first week of an ISO year is the first (Gregorian) calendar week of a year containing a Thursday. This is called week number 1, and the ISO year of that Thursday is the same as its Gregorian year.
For example, 2004 begins on a Thursday, so the first week of ISO year 2004 begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004:

大多數日期和時間日歷都遵循公歷。 ISO日歷是公歷之一的廣泛使用的變體。 ISO年度包括52或53個整周,其中一個星期從星期一開始,在星期日結束。 ISO年的第一周是包含星期四的一年中的第一個(格里高利歷)日歷周。 這稱為第1周,該周四的ISO年與其公歷年相同。
例如,2004年從星期四開始,因此ISO 2004年的第一周從2003年12月29日星期一開始,到2004年1月4日星期日結束:

Weekday number for Monday is 1 while incrementing by 1 for the coming days.

星期一的工作日數為1,而接下來的幾天則增加1。

Module:

模塊:

import datetime

Class:

類:

from datetime import date

Syntax:

句法:

isocalendar()

Parameter(s):

參數:

  • None

    沒有

Return value:

返回值:

The return type of this method is a tuple which tells us what is the ISO year, ISO week and the ISO weekday of that date.

此方法的返回類型是一個元組,它告訴我們什么是ISO年,ISO周和該日期的ISO工作日。

Example:

例:

## importing date class from datetime import date## Creating an instance x = date.today() d = x.isocalendar() print("Original date:",x) print("Today's date in isocalendar is:", d) print()x = date(2020, 1, 1) d = x.isocalendar() print("Date ", x,"in isocalendar is:", d) print()x = date(2020, 10, 27) d = x.isocalendar() print("Original date was:",x) print("ISO year:",d[0],"ISO week:",d[1],"ISO weekday:",d[2])

Output

輸出量

Original date: 2020-04-29 Today's date in isocalendar is: (2020, 18, 3)Date 2020-01-01 in isocalendar is: (2020, 1, 3)Original date was: 2020-10-27 ISO year: 2020 ISO week: 44 ISO weekday: 2

翻譯自: https://www.includehelp.com/python/date-isocalendar-method-with-example.aspx

python 示例

總結

以上是生活随笔為你收集整理的python 示例_带有示例的Python date isocalendar()方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。