Python time模块

作者: Modelstrategy | 来源:发表于2017-12-13 16:40 被阅读0次
# time 模块
import time
now = time.time()
print('seconds gone from the beginning of 1970-1-1 00:00:', now)

# 用ctime(current time)方法将纪元值转换为 字符串

print('transverted time:', time.ctime(now))

# 使用localtime() 创建 struct_time对象

print('local time: ', time.localtime(now))

# 使用gmtime() 创建 struct_time对象

print('gmtime: ', time.gmtime(now))

# 用mktime() 将 struct_time 对象转换为纪元值

print('mktime: ', time.mktime(time.localtime(now)))

# 用 strftime() 格式化 字符串  // string from time?
fmt = 'Es ist %B, %d, %Y Örtliche Zeit: %A %H:%M:%S %p'

t = time.localtime()
print(time.strftime(fmt, t))

相关文章

  • Python常用模块

    Python常用模块之time模块 Python常用模块之os模块 Python常用模块之sys模块 Python...

  • Python 入门之 内置模块 - time模块

    Python 入门之 内置模块 -- time模块 1、time模块 ​ time翻译过来就是时间,这个模块是与时...

  • Python正式课第十四天

    Python常用模块 一、时间处理模块 1. time.time() time time() 返回当前时间的时间戳...

  • Python datetime模块参考手册

    Python提供了多个内置模块用于操作日期时间,像 calendar,time,datetime。time模块提供...

  • Python的time和datetime模块

    Python的time和datetime模块 time 常用的有time.time()和time.sleep()函...

  • Python常用库

    Python常用库 一、time:时间处理模块 1.time.time() time time() 返回当前时间的...

  • python—time模块

    Python中,与时间处理有关的模块就包括:time,datetime以及calendar。 time模块 im...

  • python+AI第十课

    python常用模块 时间处理模块①.time.time()返回当前时间的时间戳 datetime主要由五个模块组...

  • Python3中datetime模块常用功能总结

    Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime。time模块我在之...

  • python的datetime

    Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime。time模块我在之...

网友评论

    本文标题:Python time模块

    本文链接:https://www.haomeiwen.com/subject/cqkzixtx.html