# 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 time模块
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- time模块中重要的函数 秒<=>时间元组<=>字符串 python日期元组的字段含义 比如元组:(2008,1,...