Python time模块
2016-05-06 15:47
531 查看
Pythontime模块
['_STRUCT_TM_ITEMS','__doc__', '__loader__', '__name__', '__package__', '__spec__', 'altzone','asctime', 'clock', 'ctime', 'daylight', 'get_clock_info', 'gmtime','localtime', 'mktime', 'monotonic', 'perf_counter', 'process_time', 'sleep','strftime', 'strptime',
'struct_time', 'time', 'timezone', 'tzname']
1.time()
time模块的核心函数time(),它返回纪元开始的秒数,返回值为浮点数,具体精度依赖于平台。
2.ctime()
浮点数一般用于存储和比较日期,但是对人类不友好,要记录和打印时间,可以使用ctime()。
3. clock()
clock()返回处理器时钟时间,它的返回值一般用于性能测试与基准测试。因此它们反映了
程序的实际运行时间。
4. gmtime()与localtime()
gmtime()用于获取UTC时间,localtime()用于获取当前时区的当前时间,UTC时间实际就是格林尼治时间,它与中国时间的时差为八个小时。
5. strptime()
用于将字符串时间转换成struct_time格式
6. strftime()
用于时间的格式化输出
7. mktime()
用于将struct_time转换成时间的浮点数表示
8. sleep()
sleep函数用于将当前线程交出,要求它等待系统将其再次唤醒,如果写程序只有一个线程,这实际上就会阻塞进程,什么也不做。
['_STRUCT_TM_ITEMS','__doc__', '__loader__', '__name__', '__package__', '__spec__', 'altzone','asctime', 'clock', 'ctime', 'daylight', 'get_clock_info', 'gmtime','localtime', 'mktime', 'monotonic', 'perf_counter', 'process_time', 'sleep','strftime', 'strptime',
'struct_time', 'time', 'timezone', 'tzname']
1.time()
time模块的核心函数time(),它返回纪元开始的秒数,返回值为浮点数,具体精度依赖于平台。
2.ctime()
浮点数一般用于存储和比较日期,但是对人类不友好,要记录和打印时间,可以使用ctime()。
3. clock()
clock()返回处理器时钟时间,它的返回值一般用于性能测试与基准测试。因此它们反映了
程序的实际运行时间。
4. gmtime()与localtime()
gmtime()用于获取UTC时间,localtime()用于获取当前时区的当前时间,UTC时间实际就是格林尼治时间,它与中国时间的时差为八个小时。
5. strptime()
用于将字符串时间转换成struct_time格式
6. strftime()
用于时间的格式化输出
7. mktime()
用于将struct_time转换成时间的浮点数表示
8. sleep()
sleep函数用于将当前线程交出,要求它等待系统将其再次唤醒,如果写程序只有一个线程,这实际上就会阻塞进程,什么也不做。
相关文章推荐
- python读取csv文件中文乱码
- 【提问答疑】Selenium + Python的Excel数据参数化
- python基础I
- python版本、文件信息及时间获取函数实例
- Python 脚本 监控数据库状态
- python的str,unicode对象的encode和decode方法
- 手把手教你用 Python 爬虫煎蛋妹纸海量图片
- python复制txt内容到另一个txt
- python SQLAlchemy 使用经验
- python新手必碰到的问题---encode与decode,中文乱码
- Sublime中配置python
- Python list dict iteration
- 练习008-009
- 你会用Python做出装逼的东西吗
- 【原】Spark之机器学习(Python版)(一)——聚类
- python: 知乎大规模(34k)用户爬虫
- 对Python的深度学习库Theano的介绍
- pythong中字符串strip的用法
- python中write没有写入是什么情况
- python 调用系统命令,并将输出重定向,输出其结果至文件或者字符串变量