Python time模块简介
来源:互联网 发布:mac炉石传说无法运行 编辑:程序博客网 时间:2024/05/16 16:07
1. 简介与说明
- 在time模块中,时间的表示有四种方式:
- 时间戳形式:以Unix纪元(1970年1月1日0点)作为原点,按与之相差的秒数表示;
- 24位字符串形式:包含年月日,时分秒以及星期几。如’Sun Nov 13 10:01:31 2016’;
- struct_time形式:一个九元素的数组结构,包含年月日,时分秒,一周的第几天,一年中的第几天以及是否是夏令时。如time.struct_time(tm_year=2016, tm_mon=11, tm_mday=13,tm_hour=2, tm_min=1, tm_sec=27, tm_wday=6, tm_yday=318, tm_isdst=0);
- 自定义形式:这是经过strftime函数转化后的一种自定义的时间模式,如’2016-11-13 02:39:55’。
2. 相关函数
获取当前时间
时间戳形式:time()
24位字符串形式: asctime() 和 ctime()
struct_time形式:gmtime() 和 localtime()
时间表示形式的转换
- 时间戳转24位字符串:ctime(timestamp)
- 时间戳转struct_time:gmtime(timestamp)和localtime(timestamp)
- struct_time转24位字符串:asctime(struct_time)
- struct_time转自定义格式:strftime(format[,t])
- 自定义格式转struct_time格式:strptime(string[,format])
- 时间戳转24位字符串:ctime(timestamp)
3. 总结
用dia画了幅图,保存的时候乱码。结果只能呈现出这个样子了。
这样就什么都看不出来了。只能在dia中截图了。下面是上面的截图样子。
关于time模块获取当前时间以及不同形式之间的转换就用这幅图做总结了。
0 0
- Python time模块简介
- python time模块详解
- python time模块详解
- python time模块详解
- python---time,datetime模块
- python time模块详解
- python time模块详解
- PYTHON模块之time
- python time模块
- python time模块详解
- Python time模块
- python time模块详解
- python time模块
- python time模块
- python之time模块
- Python time模块学习
- python time模块解析
- python time模块详解
- 机器学习算法--逻辑回归原理介绍
- Java SE基础知识
- MapReduce_TotalSort示例
- Url与Uri与URN的区别:
- 11.12
- Python time模块简介
- 学习安卓相关的网站
- Struts2 的jar包冲突如何解决?
- javascript中数组的sort()方法原理研究
- 二叉排序树
- BootStrap实战二之网站 Logo 添加
- 多线程系列-volatile
- MapReduce_SecondarySort示例
- 447. Number of Boomerangs