Python module datetime detailed

Source: Internet
Author: User

#-*-coding:utf-8-*-#python#Xiaodeng#Python module datetime detailedImportdatetime#data=datetime.date (2015,11,9) #表示日期的类#Data=datetime.time (Hour[,minute[,second[,microsecond[,tzinfo]]) #表示时间的类, starting from a small time as a parameter#Data=datetime.datetime (Year,month,day[,hour[,minute[,second[,microsecond[,tzinfo]]) #表示日期时间, is actually the first 2 comprehensive #Data=datetime.timedelta () #表示时间间隔, which is the length between two points in time#data=datetime.tzinfo () #与时区有关的相关信息" ">>> Help (DateTime) CLASSES __builtin__.object date datetime time Timedelta  Tzinfo class Date (__builtin__.object) |                              Date (year, month, day)--Date Object |  #得到一个日期对象, 3 parameters need to be passed #data =datetime.date (2015,11,8) #2015-11-08 |  Methods defined here: |                  CTime (...)      #返回一个时间风格的字符串 #data. CTime () #Sun Nov 8 00:00:00 2015 |     Return CTime () style string.       |  |            Fromordinal (...)      #将Gregorian日历时间转换为date对象, Western countries use more, here is not detailed discussion #了解即可 |     int, date corresponding to a proleptic Gregorian ordinal.       |  |          Fromtimestamp (...)      #根据给定的时间戮, returns a Date object #data. Fromtimestamp (1111111111) #2005-03-18 |     Timestamp, local date from a POSIX timestamp (like Time.time ()).       |  | IsocaLendar (...)      #data. Isocalendar () # (45, 7), #注意: Returns the tuple of the year, month, and day, returning the result of a problem, a month or so??? |     Return a 3-tuple containing ISO year, week number, and weekday.       |  |                                     Isoformat (...)      #data. Isoformat () #2015 string of -11-08 #返回格式如 ' Yyyy-mm-dd ' |     Return string in ISO 8601 format, Yyyy-mm-dd.       |  |                                     Isoweekday (...)                                          #data. Isoweekday () #1 #返回当前的星期数, such as Today Monday, returns a value of 1, or 7 if it is Sunday.      |     Return the day of the week represented by the date.      | Monday = = 1 ...       Sunday = = 7 |  |                                     Replace (...)                                          #data. Replace (2014,8,01) #2014 -08-01 #相当于string的replace替换功能, no substitution is done by default if no parameters are written      |    Return date with the new specified fields. |  |                                     Strftime (...)      #data. Strftime ('%y-%m-%d%h-%m-%s ') #2015 -11-09 00-00-00 #按照自定义风格来格式化时间字符串 |     Format, strftime () style string.       |  |                                     Timetuple (...) #返回time. Struct_time objects #data. Timetuple () #time. Struct_time (tm_year=2015, tm_mon=11, tm_m      Day=9, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=313, tm_isdst=-1) |     Return time tuple, compatible with Time.localtime ().       |  |                                     Today (...)      #data. Today () #2015 -11-09 #返回一个表示当前本地时间的datetime对象 |     Current date or Datetime:same as Self.__class__.fromtimestamp (Time.time ()).       |  |                                     Toordinal (...)                                     #返回日期对应的Gregorian Calendar date.      #了解即可 |  Return proleptic Gregorian ordinal. January 1 of Year 1 was Day 1.     |  |                                     Weekday (...)     #返回weekday, #如果是星期一, returns 0, if it is Week 2, returns 1, and so on.      |     Return the day of the week represented by the date.      | Monday = = 0 ...       Sunday = = 6 |  |  ----------------------------------------------------------------------     |       Data descriptors defined here: #数据描述符定义在这里 |  |       Day |  |       Month |  |  Year |  ----------------------------------------------------------------------class datetime (date) |       DateTime (year, month, day[, hour[, minute[, second[, Microsecond[,tzinfo] []]) |  | The year, month and day arguments is required.  Tzinfo May is None, or an | Instance of a Tzinfo subclass.      The remaining arguments may be ints or longs.  |  Methods defined here: |                                Astimezone (...)      #data. Astimezone () #根据给定的timezone对象, returns the TimeZone object converted to the local time zone #了解有这么个东西即可 | TZ-&Gt       Convert to local time in new timezone TZ |  | Combine (...)      # #不做了解 |       Date, time, datetime with same date and Time fields |  |                                 CTime (...)      #data. CTime () #Mon Nov 9 00:26:10 2015 |     Return CTime () style string.       |  |                                 Date (...)      #data. Date () #2015 -11-09 #返回日期时间对象中的日期信息 |     Return Date object with same year, month and day.       |  | DST (...)      #不做了解 |     Return self.tzinfo.dst (self).       |  |                                 Fromtimestamp (...)                                 #datetime. Fromtimestamp (timestamp[, TZ]): #根据时间戮创建一个datetime对象, parameter TZ specifies time zone information;      #data. Fromtimestamp (1111111111) #2005-03-18 09:58:31 |     timestamp[, TZ], TZ ' s local time from POSIX timestamp.       |  | Isoformat (...)                                 #data. Isoformat () #2015 -11-09t00:26:10 #了解即可 |     [Sep], string in ISO 8601 format, yyyy-mm-ddthh:mm:ss[.mmmmmm][+hh:mm].           |      |     Sep is used-separate the year from the time, and defaults to ' T '.       |  |                                 Now (...)      #data. Now () #2015 -11-09 00:39:43.894000 #现在的日期时间 |     [TZ], new datetime with TZ ' s local day and time.       |  |                                 Replace (...)                                 #data. Replace (2005,11,9,00,26,10) #2005 -11-09 00:26:10 #可以不传参      #相当于string的替换方法 |     Return datetime with new specified fields.       |  |                                 Strptime (...) #参数: #format: Formatted, such as:%y-%m-%d%h:%m:%s #string: Time string, such as: 2012- 03-05 16:26:23 #data. Strptime (' 2012-03-05 16:26:23 ', '%y-%m-%d%h:%m:%s ') #2012 -03-05 16:26:23 #返回: Date Time |     String, format, new DateTime parsed from a string (like Time.strptime ()).       |  |                                 Time (...)       #data. Time () #00:26:10 #返回日期时间中的时间, in fact, from the date and time to separate The Times |     Return time object with same time and with Tzinfo=none.       |  |                                 Timetuple (...) #data. Timetuple () #time. Struct_time (tm_year=2015, tm_mon=11, tm_mday=9, tm_hour=0, tm_min=26, tm_sec=10, Tm_wday=0, TM _yday=313, Tm_isdst=-1) #返回: Time.struct_time object #做了解即可, general purpose      Relatively few |     Return time tuple, compatible with Time.localtime ().       |  |                                 Timetz (...)      #data. Timetz () #00:26:10 #返回时间对象 |     Return time object with same time and tzinfo.       |  | Tzname (...)#不做了解 |     Return self.tzinfo.tzname (self).       |  | Utcfromtimestamp (...)      #不做了解 |     Timestamp-UTC datetime from a POSIX timestamp (like Time.time ()).       |  |                                 UtcNow (...)      #data. UtcNow () #2015 -11-08 16:48:29.194000 #返回一个当前utc时间的datetime对象 |     Return a new DateTime representing UTC day and time.       |  | Utcoffset (...)      #不做了解 |     Return Self.tzinfo.utcoffset (self).       |  | Utctimetuple (...)      #不做了解 |     Return UTC time tuple, compatible with Time.localtime ().       |  |  ----------------------------------------------------------------------     |       Data descriptors defined here: |  |  Hour |  microsecond# μs |  Minute |  second# S |          Tzinfo |  Class time (__builtin__.object) |       Time ([hour[, minute[, second[, microsecond[, Tzinfo]]]])--A Time object |  | All arguments is optional. Tzinfo May is None, or an InstanCE of | A tzinfo subclass.     The remaining arguments may be ints or longs.       |  |  Methods defined here: |     DST (...)      |     Return self.tzinfo.dst (self).       |  |                         Isoformat (...)      #data. Isoformat () #00:26:10 #返回型如 A string representation of the "HH:MM:SS" format |     Return string in ISO 8601 format, hh:mm:ss[.mmmmmm][+hh:mm].       |  |     Replace (...)      |     Return time with the new specified fields.       |  |                        Strftime (...)      #data. Strftime ('%h-%m-%s ') #00 -26-10 #返回自定义格式化字符串 |     Format, strftime () style string.       |  | Tzname (...)      #不做了解 |     Return self.tzinfo.tzname (self).       |  | Utcoffset (...)      #不做了解 |     Return Self.tzinfo.utcoffset (self).  |                            ----------------------------------------------------------------------class Timedelta (__builtin__.object) #timedelta ([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[(weeks]]) #注意timedelta的参数顺序 |     Difference between the datetime values.       |  |       Methods defined here: |  |                             Total_seconds (...)                             #总持续秒数.      Data.total_seconds () #86400.0 |     Total seconds in the duration.       |  |  ----------------------------------------------------------------------     |       Data descriptors defined here: |  |     Days:number of days.       |  |     Microseconds:number of microseconds (>= 0 and less than 1 second).       |  |     Seconds:number of seconds (>= 0 and less than 1 day).  |                            ----------------------------------------------------------------------class Tzinfo (__builtin__.object)     #tzinfo = UTC (8)----East 8, Beijing, China, #tzinfo类下的方法暂时不做了解.  |     Abstract base class for time zone info objects.       |  |       Methods defined here: |  |     DST (...)      | DST OFFSE, DateTimeT in minutes East of UTC.       |  |     FROMUTC (...)      |     DateTime in UTC, datetime in local time.       |  |     Tzname (...)      |     DateTime-String name of time zone.       |  |     Utcoffset (...)      |     datetime, Minutes east of UTC (Negative for west of UTC).       |  | ----------------------------------------------------------------------DATA maxyear = 9999 Minyear = 1 Datetime_ca PI = <capsule Object "Datetime.datetime_capi" >" "

Python module datetime detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.