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库,所以各个平 ...
随机推荐
- const常量,常量折叠,字面常量
const int a=10: 涉及到一个叫常量折叠的概念(认为我这说得太简单或者不好理解的可以google一下它获取更多信息), 即编译器虽然会给a分配空间(如果取a的地址进行操作的时候,会强迫编译 ...
- 18.Jewels and Stones(珠宝和石头)
Level: Easy 题目描述: You're given strings J representing the types of stones that are jewels, and Sre ...
- Qt 学习之路 2(7):MainWindow 简介
Qt 学习之路 2(7):MainWindow 简介 豆子 2012年8月29日 Qt 学习之路 2 29条评论 前面一篇大致介绍了 Qt 各个模块的相关内容,目的是对 Qt 框架有一个高屋建 ...
- Codeforces Round #532 (Div. 2)- A(思维)
This morning, Roman woke up and opened the browser with nn opened tabs numbered from 11 to nn. There ...
- Wireshark抓取TCP包分析
介绍 本篇文章是使用wireshrak对某个https请求的tcp包进行分析. 目的 通过抓包实际分析了解tcp包. 准备工作 在我自己机子上安装的是wireshark2.2.6版本,随机查找了某个T ...
- gulp不压缩打包layui
从网上下载的layui都是压缩包,如何打包在一个文件且不压缩呢?如下方法: 1.https://gitee.com/sentsin/layui下载源码(本文的为2.4.5版本) 2.安装nodejs( ...
- C#学习 - 关于Interlocked.CompareExchange()的用法
https://blog.csdn.net/jianhui_wang/article/details/80485517 Interlocked.CompareExchange有一组函数 名称 说明 ...
- my15_ mysql binlog格式从mixed修改为row格式
由于主库繁忙,就在从库上修改binlog格式 1. 从库切日志mysql> flush logs;Query OK, 0 rows affected (0.00 sec) mysql> f ...
- my12_xtrabackup压缩备份与恢复
xtrabackup版本 # rpm -qa | grep xtrabackup percona-xtrabackup-24-2.4.12-1.el7.x86_64 此版本为目前比较新的版本(2018 ...
- java——调用一个静态方法的时候有没有执行这个类的构造方法,以及这个类中的静态常量?
尝试一下: public class Try { final static int a = 1; public Try() { System.out.print("构造方法"); ...