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(结构体,值类 ...
随机推荐
- The package 'MySql.Data' tried to add a framework reference to 'System.Runtime' which was not found in the GAC
最近在学习Visual Studio连接mysql EF模型.在nuget中安装mysql.data时总是提示The package 'MySql.Data' tried to add a frame ...
- VSTO 开发中 应用ActionPane、CustomTaskPane
以Excel插件为例: 1. ActionPane 创建 ThisWorkbook 项目 private void ThisWorkbook_Startup(object sender, System ...
- Python学习---Python下[字典]的学习
Python中唯一的映射类型(哈希表) -->Java中的HashMap<K,V> Python对key进行了哈希函数运算,根据计算的结果决定value的存储地址,所以字 ...
- SAP技术专家的ABAP调试器培训材料
首先弄清楚ABAP Classic调试器和新调试器的区别: Classic debugger: (1) Static breakpoint a. BREAK-POINT : non-user spec ...
- 200. Number of Islands + 695. Max Area of Island
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...
- delegate 和 event
delegate 和 event 观察者模式 这里面综合了几本书的资料. 需求 有这么个项目: 需求是这样的: 一个气象站, 有三个传感器(温度, 湿度, 气压), 有一个WeatherData对象, ...
- Webpack笔记(三)——一款破产版脚手架的开发
前些天一直在学习入门Webpack,后来尝试了自己搭建一下一个简单的React开发环境,后来就在想可不可以自己写一个简单的脚手架,以免每次搭建一个简单的开发环境都需要自己一个个的配置,这样很麻烦,使用 ...
- reactnative 原生组件通信原理
http://www.csdn.net/article/2015-11-27/2826345-compare-React-Native-with-ExMobi 原生组件通信原理 React Nativ ...
- Linux系统中while管道的
因为项目从AIX系统迁移到了RedHat系统,之前写过的一段Shell脚本不能成功运行,经过分析,锁定了关键代码如下: readFileContent(){ currentFile=$ fileSho ...
- BZOJ2342:[SHOI2011]双倍回文(Manacher)
Description Input 输入分为两行,第一行为一个整数,表示字符串的长度,第二行有个连续的小写的英文字符,表示字符串的内容. Output 输出文件只有一行,即:输入数据中字符串的最长 ...