Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将两个动作之间的时间差 (diff) 转换为人类可读的时间。
我怎么能用python做到这一点?我尝试了类似的东西
diff = 49503757 datetime.time(0,0,0,diff)
但是 diff 值太长,datetime 需要一个介于 0 和 999999 之间的微秒值,而我在这个例子中的 diff 是 49503757。
>>> from datetime import timedelta >>> str(timedelta(microseconds=49503757)) '0:00:49.503757'