Skip to main content
 首页 » 编程设计

Python 箭头毫秒

2025年05月04日12webabcd

我想弄清楚一件简单的事情 - 如何将 arrow.Arrow 对象转换为毫秒。我正在阅读以下 thread但我仍然不清楚如何以毫秒为单位获得一个长数字。

我想要这样的东西:

def get_millis(time: arrow.Arrow): 
     ... some magic goes here ... 
 
 
print(get_millis(time))      
OUTPUT:  
1518129553227  

谢谢

请您参考如下方法:

这是一个不雅的答案:从您的链接问题中,您可以将毫秒作为字符串获取,然后将它们添加到时间戳中:

import arrow 
now = arrow.utcnow() 
s = now.timestamp 
ms = int(now.format("SSS")) 
print(s * 1000 + ms) 

打印:

1518131043594