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

歡迎訪問 生活随笔!

生活随笔

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

python

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

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

python 示例

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

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

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

It is an instance method which means that it works on an instance of the class. It returns a time.struct_time which is an object with a named tuple interface containing nine elements.

這是一個實例方法,這意味著它可以在類的實例上工作。 它返回一個time.struct_time ,它是一個具有包含9個元素的命名元組接口的對象。

Following values are present in time.struct_time object:

time.struct_time對象中存在以下值:

IndexAttributeValue
0tm_year(for example, 1993)
1tm_monrange [1, 12]
2tm_mdayrange [1, 31]
3tm_hourrange [0, 23]
4tm_minrange [0, 59]
5tm_secrange [0, 61]
6tm_wdayrange [0, 6], Monday is 0
7tm_ydayrange [1, 366]
8tm_isdst0, 1 or -1; see below
N/Atm_zoneabbreviation of timezone name
N/Atm_gmtoffoffset east of UTC in seconds
指數 屬性 值
0 tm_year (例如1993)
1個 tm_mon 范圍[1,12]
2 tm_mday 范圍[1,31]
3 tm_hour 范圍[0,23]
4 tm_min 范圍[0,59]
5 tm_sec 范圍[0,61]
6 tm_wday 范圍[0,6],星期一為0
7 tm_yday 范圍[1,366]
8 tm_isdst 0、1或-1; 見下文
不適用 tm_zone 時區名稱的縮寫
不適用 tm_gmtoff 以秒為單位偏移UTC以東

A date timetuple is equivalent to,

日期時間元組等于

time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))

Since it is a date object, time values are missing because of which those attributes are set to zero(index- 3,4,5). As date object is naive, the timezone information are also missing.

由于它是一個日期對象,因此缺少時間值,因此這些屬性設置為零(索引3、4、5)。 由于日期對象太幼稚,因此時區信息也丟失了。

Module:

模塊:

import datetime

Class:

類:

from datetime import date

Syntax:

句法:

timetuple()

Parameter(s):

參數:

  • None

    沒有

Return value:

返回值:

The return type of this method is a time.struct_time object which contains date information.

此方法的返回類型是time.struct_time對象,其中包含日期信息。

Example:

例:

## Python program explaining the ## use of date class instance methodsfrom datetime import date## Creating an instance x = date(2020, 4, 29) print("Current date is:", x) print()d = x.timetuple() print("The tuple of the date object", d) print()print("We can also access individual elements of this tuple") for i in d:print(i)

Output

輸出量

Current date is: 2020-04-29The tuple of the date object time.struct_time(tm_year=2020, tm_mon=4, tm_mday=29, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=120, tm_isdst=-1)We can also access individual elements of this tuple 2020 4 29 0 0 0 2 120 -1

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

python 示例

總結

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

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