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(结构体,值类 ...
随机推荐
- 【Leetcode】【Medium】Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- 【转】Linux中/etc/profile,/etc/bashrc,~/.profile,~/.bashrcd的区别
//因为在原文章中博主说以下内容是网友说的,所以我就只加个转了,找不到原作者 /etc/profile,/etc/bashrc 是系统全局环境变量设定 ~/.profile,~/.bashrc用户家目 ...
- css笔记 2
定义一个类选择器.center {text-align: center} h1 有 center 类.这意味将遵守 ".center" 选择器中的规则.<h1 class=& ...
- docker中自定ingress网络
在某些时候,docker自动生成的ingress网络会与服务器上已经存在的网络产生冲突,这个时候,你需要自定义ingress. 在自定义前,你需要删除所有有端口发布的服务. 使用命令docker ne ...
- easyui学习笔记9—手风琴格子的增,删和选择
这一篇中我们将看看如何给手风琴动态的增加,删除格子,怎样选择某一个格子的. 1.先看看引用的资源 <link rel="stylesheet" href="jque ...
- 利用Kali进行WiFi钓鱼测试实战
文中提及的部分技术可能带有一定攻击性,仅供安全学习和教学用途,禁止非法使用.请不要做一只咖啡馆里安静的猥琐大叔. 写在前面 从至少一年前我就一直想在自己跑kali的笔记本上架个钓鱼热点.然而由于网上的 ...
- [原]SDL开发教程
SDL开发库:http://www.libsdl.org/ SDL中文开发教程:http://tjumyk.github.io/sdl-tutorial-cn/index.html SDL英文版开发教 ...
- CSAPP Bomb Lab记录
记录关于CSAPP 二进制炸弹实验过程 (CSAPP配套教学网站Bomb Lab自学版本,实验地址:http://csapp.cs.cmu.edu/2e/labs.html) (个人体验:对x86汇编 ...
- CTSC2018 && APIO2018 && SDOI2018R2游记
Day -? 占个坑先.希望CTSC,APIO别打铁,R2别滚粗QAQ CTSC Day 0 早起坐车睡觉颓废报道颓废 反正游记就是咕懒得写了 Day 1 早上四点被xp的闹钟吵醒(???还两次) 幸 ...
- 搭建nlp_server服务器
这是文档 如何启动斯坦福NLP-Service 1.sudo apt-get install gearman-job-server安装gearman-server 2.启动gearman服务: gea ...