【发布时间】:2012-03-22 20:48:53
【问题描述】:
我需要以time.time() 形式获得的浮点值以("%m/%d/%Y %H:%M:%S") 格式表示时间。
我已经有一个 time.time() 形式的值。例如,我已经有了每 0.3 秒从设备获取的值,例如 1332449493.0,......,然后我想将 1332449493.0 转换为 strftime 格式。
前: time.strftime("%m/%d/%Y %H:%M:%S", 1332449493.0) 将抛出 TypeError 因为 strf 需要 9 项元组而不是浮点数。
【问题讨论】:
-
通过...使用
strftime函数。你读过文档吗? -
是的,但是 time.strftime("%m/%d/%Y %H:%M:%S", time.localtime(1332449493.0)) 是我自 time.strftime 以来一直在寻找的("%m/%d/%Y %H:%M:%S", 1332449493.0) 不是正确的方法。
标签: python