Python time模块

# 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))
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • time模块中重要的函数 秒<=>时间元组<=>字符串 python日期元组的字段含义 比如元组:(2008,1,...
    EmptyBottl_520d阅读 166评论 0 0
  • 1.1.1.1time 1、help(time)之后可以知道time有2种时间表示形式: 1、timestam...
    PythonMaO阅读 768评论 0 0
  • 一、python time模块的简介 在Python编程语言中,只要涉及到时间日期的操作,就会用到这个time模块...
    一只写程序的猿阅读 834评论 0 0
  • 今天是陈泰皓爷爷的生日,晚上放学我们就开车回老家了。陪爷爷吃了顿饭,没时间在家呆太久,今晚不光要练亲子广场舞...
    史晓辉阅读 332评论 0 2
  • 上午,我正看着谢师傅换办公室门锁,就听见手机信息提示音,还没等我解锁,老板就过来说群里有消息,回个收到,因为别人的...
    冰点晚安阅读 149评论 0 0