小编Gre*_*een的帖子

无法在 python 中转换 13 位 UNIX 时间戳

对这个还是陌生的。我试图将 13 位时间戳转换为您可以阅读但没有运气的内容。我正在做的是从楼宇自动化系统中采样温度数据。这是我正在使用的代码。我错过了一些非常简单的东西。我可以朝正确的方向戳一下吗?

when_updated=driver.find_element_by_name("_lastUpdated")
timestamp=when_updated.get_attribute("value")
print("Timestamp:", timestamp)

nos=10  # Number of samples
freq=5  # Sampling frequency
print("\nTemperature & timestamp, sampled every", freq, "seconds:")
while True:
     ts=driver.find_element_by_name("_lastUpdated").get_attribute("value")
     print("\nTemperature: ", element.text, "read at:", ts)
     time.sleep(freq)


driver.switch_to_default_content()
Run Code Online (Sandbox Code Playgroud)

输出

Temperature:

Timestamp: 0

Temperature & timestamp, sampled every 5 seconds:

Temperature:   read at: 0

Temperature:  21.0 ºC read at: 1520912895599

Temperature:  21.0 ºC read at: 1520912901432

Temperature:  21.0 ºC read at: 1520912907070
Run Code Online (Sandbox Code Playgroud)

python unix timestamp

-3
推荐指数
1
解决办法
3819
查看次数

标签 统计

python ×1

timestamp ×1

unix ×1