# -*- 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. const 变量修饰 研究

    #include<stdio.h> #include<iostream> using namespace std; struct A { ;} ;} }; int main() ...

  2. AD各种布线方法总结

    1.常规布线:不详细说了,是个人就知道怎么弄.需要说明的是在布线过程中,可按小键盘的*键或大键盘的数字2键添加一个过孔:按L键可以切换布线层:按数字3可设定最小线宽.典型线宽.最大线宽的值进行切换. ...

  3. CSS-设置Footer始终在页面底部

    Footer顾名思义页脚,如果内容多的时候在底部时感官很好,但是当内容变少(无法撑开一屏的时候)footer不固定在底部,影响美观,对于已经从事前端工作的工作的来说应该是比价工作中入门级别的问题了,由 ...

  4. iOS开发-Launch Image和Launch Screen

    Launch Image是App的启动图片,LaunchScreen是iOS8之后的功能,两者都可以设置app的启动图片.iOS8之后官方的推荐了使用Launch screen.xib,在xib的中通 ...

  5. FileProvider N 7.0 升级 安装APK 选择文件 拍照 临时权限 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  6. Windows 安装配置 JIRA

    MySQL-5.5.28 JDK1.6.0_21 JIRA功能全面,界面友好,安装简单,配置灵活,权限管理以及可扩展性方面都十分出色. 一.MySQL建库和建账号 1. mysql中创建数据库jira ...

  7. 【Java】Java-fastjson-基本使用方法

    Java-fastjson-基本使用方法 fastjson maven_百度搜索 Maven Repository: com.alibaba » fastjson » 1.2.44 fastjson ...

  8. JavaScript代码不执行

    一天先后有两个同事问我为啥他的js代码出现了莫名其妙的问题 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "h ...

  9. Jquery Ajax 返回数据类型变成document

    下面是我写的一段Jquery Ajax的代码,在chrome下没有问题,在firefox下就算是返回success也提示"系统正忙"; $.ajax({ url: "fa ...

  10. 基于PHP构建OAuth 2.0 服务端 认证平台

    OAuth2.0 认证服务 安装 你可以在github上下载OAuth Server PHP,也可以用下列命令下载,不过内容都是一样的 mkdir my-oauth2-walkthrough cd m ...