time和datetime模块

- time.timezone
- time.altzone
返回夏令时与标准时间的差(有的国家使用夏令时)
- time.daylight
我国不使用夏令时,此处返回0
- time.time()
获取时间戳,返回一个float数值
- time.sleep(seconds)
延时seconds秒
- time.gmttime(timestamp)
将一个时间戳转化为UTC时区(标准时区)的元组格式时间
- time.localtime(timestamp)
- time.mktime(struct_time)
将结构化时间元组(struct_time)转化为时间戳
- time.strftime(format,p_tuple)
| 格式 | 含义 | 备注 |
|---|---|---|
| %a | 本地(locale)简化星期名称 | |
| %A | 本地完整星期名称 | |
| %b | 本地简化月份名称 | |
| %B | 本地完整月份名称 | |
| %c | 本地相应的日期和时间表示 | |
| %d | 一个月中的第几天(01 - 31) | |
| %H | 一天中的第几个小时(24小时制,00 - 23) | |
| %I | 第几个小时(12小时制,01 - 12) | |
| %j | 一年中的第几天(001 - 366) | |
| %m | 月份(01 - 12) | |
| %M | 分钟数(00 - 59) | |
| %p | 本地am或者pm的相应符 | |
| %S | 秒(01 - 61) | |
| %U | 一年中的星期数。(00 - 53星期天是一个星期的开始。)第一个星期天之前的所有天数都放在第0周。 | |
| %w | 一个星期中的第几天(0 - 6,0是星期天) | |
| %W | 和%U基本相同,不同的是%W以星期一为一个星期的开始。 | |
| %x | 本地相应日期 | |
| %X | 本地相应时间 | |
| %y | 去掉世纪的年份(00 - 99) | |
| %Y | 完整的年份 | |
| %Z | 时区的名字(如果不存在为空字符) | |
| %% | ‘%'字符 |
- time.strptime(time_string,format)
- time.asctime(p_tuple)
将时间元组转化为字符形式,参数为空则转化当前时间元组
- time.ctime(timestamp)
将时间戳转化为字符形式,参数为空则转化当前时间戳
<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">
time和datetime模块的更多相关文章
- python中datetime模块
Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime.time模块我在之前的文章已经有所介绍,它提供 的接口与C标准库time.h基本一致.相比于time模块 ...
- python datetime模块参数详解
Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime.time模块,它提供 的接口与C标准库time.h基本一致.相比于time模块,datetime模块的接 ...
- Python处理时间 time && datetime 模块
Python处理时间 time && datetime 模块 个人整理,获取时间方式: import datetime import time #获取当前时间:Thu Nov 03 ...
- python time模块和datetime模块详解
一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...
- python-Day5-深入正则表达式--冒泡排序-时间复杂度 --常用模块学习:自定义模块--random模块:随机验证码--time & datetime模块
正则表达式 语法: mport re #导入模块名 p = re.compile("^[0-9]") #生成要匹配的正则对象 , ^代表从开头匹配,[0 ...
- python datetime模块strptime/strptime format常见格式命令_施罗德_新浪博客
python datetime模块strptime/strptime format常见格式命令_施罗德_新浪博客 python datetime模块strptime/strptime form ...
- Python datetime模块的datetime类
datetime模块定义了下面这几个类: datetime.date:表示日期的类.常用的属性有year, month, day. datetime.time:表示时间的类.常用的属性有hour, m ...
- python处理时间--- datetime模块
1 Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime.time模块我在之前的文章已经有所介绍,它提供的接口与C标准库time.h基本一致.相比于tim ...
- Python,datetime模块实例
Python的标准模块datetime模块,在我们的工作中应用非常频繁,下面对datetime中常用的方法进行了总结和测试:对每一个方法都使用了单元测试框架Unittest来配合测试. 主要的类型有: ...
- python3 time模块与datetime模块
time模块 在Python中,通常有这几种方式来表示时间:1)时间戳 2)格式化的时间字符串 3)元组(struct_time)共九个元素.由于Python的time模块实现主要调用C库,所以各个平 ...
随机推荐
- github的使用 sourceTree
http://www.cnblogs.com/Jenaral/p/5655958.html
- xampp 在 windows下 配置 fcgi... 和 opcache 等 优化操作
首先 修改 xampp 的 httpd.conf:(底部加入.方便修改) #fast-cgi 模式 LoadModule fcgid_module modules/mod_fcgid.so <I ...
- windows_study_2
描述:如何确定像%ProgramFiles%这样格式的目录的具体位置? 解决:运行——cmd——echo %ProgramFiles%——回车——界面就显示出目录位置了.
- A. Free Cash
A. Free Cash time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- 前端CSS css引入方式 css选择器 css选择器优先级
一. CSS介绍 CSS(Cascading Style Sheet,层叠样式表)定义如何显示HTML元素,给HTML设置样式,让它更加美观. 当浏览器读到一个样式表,它就会按照这个样式表 ...
- NFS网络储存系统
为什么用NFS网络文件存储系统? 1)实现数据信息统一一致 2)节省局域网数据同步传输的带宽 3)节省网站架构中服务器硬盘资源 NFS系统存储原理介绍 RPC服务类似一个中介服务,NFS服务端与NFS ...
- 惠普台式机在UEFI BIOS设置通电自动开机 影响电脑自动重启关不了机设置
设置通电自动开机 影响电脑自动重启关不了机设置 惠普台式机在UEFI BIOS中 1. 开机时不断点击F10键进入BIOS,选择Advanced(高级)然后选择Boot Options,点击回车 ...
- .NET Core单元测试覆盖率统计coverlet配置和使用
https://segmentfault.com/a/1190000017569492 需要使用: 使用 Moq 测试.NET Core 应用 https://www.cnblogs.com/c ...
- java——arr == null || arr.length == 0
这两者是不同的: arr == null; int[] arr = null; arr.length == 0; int[] arr =new int[0];
- flume failed to start agent because dependencies were not found in classpath
FLUME_CLASSPATH=/root/flume/lib/ copied comon jar files from hadoop folder to the flume folder. cp / ...