Python time 模块 属性、func 关系
来源:互联网 发布:waves gtr for mac 编辑:程序博客网 时间:2024/06/05 19:57
前言
网上有很多大神和前辈都对python time 模块做了详细的阐述。
但是可能是本博主有点笨,每次要用的时候总得先查查。于是想再前人的基础上做个小总结,方便自己记忆和应用。 如果能帮助到其他人,也是极好的。:)
参考的原文
Python中time模块详解(转)
Python模块学习 —- time 日期时间处理
https://docs.python.org/2/library/time.html?highlight=time#module-time
time关系图
time 模块中与世界同步的变量主要是timestamp 和struct_time. 但是我们用到的往往是: timestamp/time string(如 ‘Tue Apr 14 10:51:33 2015’ 或 “2015:10:51:33”)
于是博主在用time模块的时候都会有点小晕。 于是画出下面的图,方便记忆。
举例
接下来举例一些常用的:
#常量str_fmt = "%a, %d %b %Y %H:%M:%S"time_str = "Tue, 14 Apr 2015 12:52:50"
- 获取当前时间戳:
time.time()
- 获取当前时间string :
time.ctime()/time.asctime()
- 格式化输出当前时间:
time.strftime(str_fmt,time.localtime())
- 将字符串时间转化成struct_time:
time.strptime(time_str,str_fmt)
- 将字符串时间转化为时间戳:
time.mktime(time.strptime(time_str, str_fmt))
其他
time的其他属性、func:
time.accept2dyear: 1time.altzone: -32400time.daylight: 0time.timezone: -28800time.tzname: ('China Standard Time', 'China Daylight Time')time.sleep(s): <built-in function sleep> ==> Sleep for s secondstime.clock(): <built-in function clock> ==> float cpu time
0 0
- Python time 模块 属性、func 关系
- 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模块解析
- UIAlertView 在IOS8.3中崩溃问题
- IOS 警告 汇总
- 腾讯技术研发一面总结
- Xcode6 新特性
- 汉字编码问题及用C程序实现将GB2312的6763个汉字按输出
- Python time 模块 属性、func 关系
- Objective-C中关于NSArray, NSDictionary, NSNumber等写法的进化
- Android自定义进度条
- linux xargs
- VirtualBox Ubuntu eth0 missing
- AsyncTask解析
- mac iterm2快捷键
- 基于REST架构的Web Service设计
- iOS微博第三方客户端开发笔记一:申请oAuth2.0认证