PyPI - Datetime
PyPI for Python 3.7
import datetime
timedelta Object
https://docs.python.org/3.7/library/datetime.html#timedelta-objects
Constructor:
datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
It also has a lot of operations. See the Documents for detail.
date Object
https://docs.python.org/3.7/library/datetime.html#date-objects
Datetime object is a combination of a date and a time. I like to use datetime object instead.
datetime Object
https://docs.python.org/3.7/library/datetime.html#datetime-objects
Constructor:
datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)datetime.datetime.fromtimestamp(timestamp, tz=None),By timestampdatetime.datetime.combine(date, time, tzinfo),Combine date object and time objectdatetime.datetime.strptime(date_string, format),By string and format
Ordinal Date is the proleptic Gregorian ordinal of the date. It is the count from 0001-01-01, just like timestamp.
Instance methods:
(Notice: a is the name of a exist datetime object)
a.replace(), Return a datetime with the same attributes, except for those attributes given new values.a.astimezone(), Return a datetime object with the timezone you give.a.timetuple(), Return a tuple. You can pick up what you need by index or others.a.toordinal(), Return the ordinal.a.timestamp(), Return the timestamp.a.strftime(format), Return the format string.
timezone Object
https://docs.python.org/3.7/library/datetime.html#timezone-objects
datetime.timezone(offset), The offset attribute must be timedelta.
String format:
(strftime --> string from time. strptime())
https://docs.python.org/3.7/library/datetime.html#strftime-and-strptime-behavior
| Directive | Tips | Meaning | Example |
|---|---|---|---|
%Y |
Year | 4 bits Year | 0001, 0002,..., 2019 |
%m |
Month | 1/2 bits Month | 01, 02, ..., 12 |
%d |
Day | 1/2 bits Day | 01, 02, ..., 31 |
%H |
Hour | 2 bits Hour | 00, 01, ..., 23 |
%M |
Minute | 2 bits Minute | 00, 01, ..., 59 |
%S |
Second | 2 bits Second | 00, 01, ..., 59 |
%w |
Week | 1 bit, 0 for Sun. and 6 is Sat. | 0, 1, ..., 6 |
PyPI - Datetime的更多相关文章
- python模块概况,json/pickle,time/datetime,logging
参考: http://www.cnblogs.com/wupeiqi/articles/5501365.html http://www.cnblogs.com/alex3714/articles/51 ...
- python模块知识一 自定义模块、time、datetime时间模块
第五章 模块 1.自定义模块: 模块分类: 内置模块(标准库)-- python解释器自带的.py文件(模块) 第三方模块(各种大神写的)-- 需要额外下载(并发编程pypi) 自定义模块(自己写的) ...
- 自定义模块,time,datetime以及random
自定义模块,time,datetime以及random 1.自定义模块 自定义一个模块 import #导入 (拿工具箱) 模块分类 1.内置模块(标准库) --python解释器自带的.py文件(模 ...
- Python模块01/自定义模块/time模块/datetime模块/random模块
Python模块01/自定义模块/time模块/datetime模块/random模块 内容大纲 1.自定义模块 2.time模块 3.datetime模块 4.random模块 1.自定义模块 1. ...
- C# DateTime与时间戳转换
C# DateTime与时间戳的相互转换,包括JavaScript时间戳和Unix的时间戳. 1. 什么是时间戳 首先要清楚JavaScript与Unix的时间戳的区别: JavaScript时间戳: ...
- C# DateTime日期格式化
在C#中DateTime是一个包含日期.时间的类型,此类型通过ToString()转换为字符串时,可根据传入给Tostring()的参数转换为多种字符串格式. 目录 1. 分类 2. 制式类型 3. ...
- 在面试中忽然发现DateTime的一些...
今天说说我面试中碰到的一个小问题,在我问起DateTime为什么无法赋值NULL值,一般第一反应都认为它是值类型,不是引用类型,但随后我查阅了度娘自我学习到它是结构类型,那么随之而然就无法赋值NULL ...
- LINQ to SQL语句(14)之Null语义和DateTime
Null语义 说明:下面第一个例子说明查询ReportsToEmployee为null的雇员.第二个例子使用Nullable<T>.HasValue查询雇员,其结果与第一个例子相同.在第三 ...
- .NET DateTime类型变量作为参数时设置默认值
一个小的 Tips. .NET 中函数参数的默认值需要是编译时常量.如果参数是引用类型,可以设置Null,如果是值类型,可以设置相应的编译时常量,如整型可以用整数,但对于DateTime(结构体,值类 ...
随机推荐
- application/x-www-form-urlencode 和 multiple/form-data
一.概述 在学习ajax的时候,如果用post请求,需要设置如下代码. ajax.setRequestHeader("content-type","application ...
- mongodb 3.4复制集配置
1:启动三个实例 /bin/mongod --config /home/mongodb/db27017/mongodb27017.conf /bin/mongod --config /home/mon ...
- Python3.x 安装Scrapy框架
先判断pip是否已经安装 pip --version 确认已经安装后,使用pip安装库 pip3 install PackageName eg: pip3 install Scrapy 报错解决方案 ...
- 使用UIScreenEdgePanGestureRecognizer写iOS7侧边栏
使用UIScreenEdgePanGestureRecognizer写iOS7侧边栏 A UIScreenEdgePanGestureRecognizer looks for panning (dra ...
- Python初学者第六天 列表操作练习
6day 列表练习: 1.创建一个空列表,命名为names,往里面添加old_drilver,rain,jack,shanshan,peiqi,black_girl: names = [] names ...
- vue + element-ui 制作tab切换(切换vue组件,踩坑总结)
本篇文章使用vue结合element-ui开发tab切换vue的不同组件,每一个tab切换的都是一个新的组件. 1.vue如何使用element-ui 上一篇文章已经分享了如何在vue中使用eleme ...
- January 30 2017 Week 5 Monday
I can accept defeat but could not accept to give up. 我可以接受失败,但不能接受放弃. Fortune has not always smiled ...
- GO语言(八) defer注意点
package main import ( "net" "os" "fmt" "io/ioutil" ) func Cl ...
- SAP S/4HANA使用ABAP获得生产订单的状态
在S/4HANA里,我们如何根据一个销售订单的行项目,查看对应的生产订单状态? 双击行项目: 点击Schedule line: 这里就能看到生产订单的ID和状态了. 其中订单的状态存储在表vsaufk ...
- PHP------面向对象的特性
面向对象的特性 一.面向对象有三大特性: 封装.继承.多态.(非常重要,第一要记住!!!!!!!!!!) 二.封装 封装就是用来做类的,把一个类封装起来.做类不能随便的做.我们做类不能随便去写一个类, ...