# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python之模块datetime详解 import datetime
#data=datetime.date(2015,11,9)#表示日期的类
#data=datetime.time(hour[,minute[,second[,microsecond[,tzinfo]]]])#表示时间的类,从小时时间开始为参数
#data=datetime.datetime(year,month,day[,hour[,minute[,second[,microsecond[,tzinfo]]]]])#表示日期时间,其实就是前面2个综合
#data=datetime.timedelta()#表示时间间隔,即两个时间点之间的长度
#data=datetime.tzinfo()#与时区有关的相关信息 '''
>>> help(datetime)
CLASSES
__builtin__.object
date
datetime
time
timedelta
tzinfo class date(__builtin__.object)
| date(year, month, day) --> date object
| #得到一个日期对象,需传递3个参数
#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对象,西方国家使用比较多,此处不详细展开讨论
#了解即可
| int -> date corresponding to a proleptic Gregorian ordinal.
|
| fromtimestamp(...) #根据给定的时间戮,返回一个date对象
#data.fromtimestamp(1111111111)#2005-03-18
| timestamp -> local date from a POSIX timestamp (like time.time()).
|
| isocalendar(...)
#data.isocalendar()#(2015, 45, 7),
#注意:返回的年、月、日的元组,返回结果有问题,45个月???
| Return a 3-tuple containing ISO year, week number, and weekday.
|
| isoformat(...)
#data.isoformat()#2015-11-08
#返回格式如'YYYY-MM-DD'的字符串
| Return string in ISO 8601 format, YYYY-MM-DD.
|
| isoweekday(...)
#data.isoweekday()#1
#返回当前的星期数,如今天星期一,则返回数值1,如为星期天,则返回7 | 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替换功能,如果不写参数则默认不做替换处理 | Return date with 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对象
#data.timetuple()#time.struct_time(tm_year=2015, tm_mon=11, tm_mday=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日期.
#了解即可
| Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.
|
| weekday(...)
#返回weekday,
#如果是星期一,返回0,如果是星期2,返回1,以此类推.
| 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 are required. tzinfo may be None, or an
| instance of a tzinfo subclass. The remaining arguments may be ints or longs. | Methods defined here:
| astimezone(...)
#data.astimezone()#根据给定的timezone对象,返回转换为本地时区的timezone对象
#了解有这么个东西即可
| tz -> 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对象,参数tz指定时区信息;
#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 to 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:格式化,如:%Y-%m-%d %H:%M:%S
#string:时间字符串,如: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
#返回:日期时间
| string, format -> new datetime parsed from a string (like time.strptime()).
|
| time(...)
#data.time()#00:26:10
#返回日期时间中的时间,其实就是从日期时间中把时间分离出来 | Return time object with same time but 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对象
#做了解即可,一般用的比较少
| 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#微秒
| minute
| second#秒
| tzinfo
| class time(__builtin__.object)
| time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) --> a time object
|
| All arguments are optional. tzinfo may be 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
#返回型如"HH:MM:SS"格式的字符串表示
| Return string in ISO 8601 format, HH:MM:SS[.mmmmmm][+HH:MM].
|
| replace(...)
| Return time with 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 two 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)----东8区北京时间
#tzinfo类下的方法暂时不做了解.
| Abstract base class for time zone info objects.
|
| Methods defined here:
|
| dst(...)
| datetime -> DST offset 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_CAPI = <capsule object "datetime.datetime_CAPI">
'''

python之模块datetime详解的更多相关文章

  1. 【转载】Python日期时间模块datetime详解与Python 日期时间的比较,计算实例代码

    本文转载自脚本之家,源网址为:https://www.jb51.net/article/147429.htm 一.Python中日期时间模块datetime介绍 (一).datetime模块中包含如下 ...

  2. python——pickle模块的详解

    pickle模块详解 该pickle模块实现了用于序列化和反序列化Python对象结构的二进制协议. “Pickling”是将Python对象层次结构转换为字节流的过程, “unpickling”是反 ...

  3. Python Deque 模块使用详解,python中yield的用法详解

    Deque模块是Python标准库collections中的一项. 它提供了两端都可以操作的序列, 这意味着, 你可以在序列前后都执行添加或删除. https://blog.csdn.net/qq_3 ...

  4. python时间模块time详解

    在平常的代码中,我们常常需要与时间打交道.在Python中,与时间处理有关的模块就包括:time,datetime以及calendar.这篇文章,主要讲解time模块. 在开始之前,首先要说明这几点: ...

  5. python re模块findall()详解

    今天写代码,在写到郑泽的时候遇到了一个坑,这个坑是re模块下的findall()函数. 下面我将结合代码,记录一下 import re string="abcdefg acbdgef abc ...

  6. Python: json模块实例详解

    ref:https://www.jianshu.com/p/e29611244810 https://www.cnblogs.com/qq78292959/p/3467937.html https:/ ...

  7. python子进程模块subprocess详解与应用实例 之三

    二.应用实例解析 2.1 subprocess模块的使用 1. subprocess.call >>> subprocess.call(["ls", " ...

  8. python子进程模块subprocess详解与应用实例 之一

    subprocess--子进程管理器 一.subprocess 模块简介 subprocess最早是在2.4版本中引入的. subprocess模块用来生成子进程,并可以通过管道连接它们的输入/输出/ ...

  9. python json模块 超级详解

    JSON(JavaScript Object Notation, JS 对象标记) 是一种轻量级的数据交换格式.JSON的数据格式其实就是python里面的字典格式,里面可以包含方括号括起来的数组,也 ...

随机推荐

  1. 【转】memcached分布式部署

    FROM : http://www.tuicool.com/articles/777nE3j memcache和memcached两者使用起来几乎一模一样. $mem = new Memcache; ...

  2. [转]Linux常用命令大全

    From : http://www.php100.com/html/webkaifa/Linux/2009/1106/3485.html 系统信息 arch 显示机器的处理器架构(1) uname - ...

  3. Java NIO: Non-blocking Server

    Even if you understand how the Java NIO non-blocking features work (Selector, Channel, Buffer etc.), ...

  4. uva 400 Unix ls 文件输出排版 排序题

    这题的需要注意的地方就是计算行数与列数,以及输出的控制. 题目要求每一列都要有能够容纳最长文件名的空间,两列之间要留两个空格,每一行不能超过60. 简单计算下即可. 输出时我用循环输出空格来解决对齐的 ...

  5. hdu 3660 Alice and Bob's Trip(树形DP)

    Alice and Bob's Trip Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  6. [leetcode]Search a 2D Matrix @ Python

    原题地址:https://oj.leetcode.com/problems/search-a-2d-matrix/ 题意: Write an efficient algorithm that sear ...

  7. SQL-根据多个条件更新数据

    根据多个条件更新数据 UPDATE sphwph SET BKXSHL=t2.BKXSHL FROM sphwph t1,sphwph_170420 t2 --(SELECT a.* FROM dbo ...

  8. Linq-批量删除方法

    linq中批量删除用DeleteAllOnSubmit,里面的参数是数据集 传入某要删除的ID列表,使用对象的Contains方法与数据库中值比较,相同就删除. //批量删除 public void ...

  9. AOP中Advice执行两遍的原因

    在我的spring项目中,Aop的Advice执行了两边,就好像拦截了两遍一样. 原因是:切面应该切到接口的实现类上,而不是接口上

  10. js获取当月最后一天

    构造函数 new Date(); new Date(value); new Date(dateString); new Date(year, month[, day[, hour[, minutes[ ...