【问题标题】:Python display millisecond in h"m's format [duplicate]Python以h“m的格式显示毫秒[重复]
【发布时间】:2015-08-06 08:00:03
【问题描述】:

我有一个通过外观运行的代码,并对符合条件的调用的持续时间求和,调用持续时间以毫秒为单位。 今天,输出是毫秒,但我想显示的是以下格式 hh"mm'ss。

请指教, 尼尔

    sumout = 0
    x = 0
    y = 0
    for call in facade.getCalls(filter=[Call.setup_start_ts >= beg_ts, Call.setup_start_ts <= end_ts, Call.src_user == user]):
       try:
           sumout += call.call_time
           x += 1
       except TypeError:
           pass;

    facade.addResult({
                    'user':user,
                    'total_Outgoing': x,
                    'total_Outgoing_Duration': sumout,})

【问题讨论】:

  • 你有什么问题?
  • 我不认为这是第一个问题的重复,因为那个问题与语言无关。它有一个用 Python 编写的答案,但它隐藏了大约 20 个答案。标记为重复的第二个问题可能仍然是重复的。我不确定如何在不删除第二个的情况下删除第一个标志。

标签: python


【解决方案1】:

重复:How to convert milliseconds into human readable form?

又快又脏:

>>> print datetime.timedelta(milliseconds=465469874645)
5387 days, 9:11:14.645000

【讨论】:

    猜你喜欢
    • 2023-03-22
    • 2018-06-21
    • 2017-04-10
    • 2014-01-09
    • 2013-07-28
    • 2021-10-11
    • 2016-05-22
    相关资源
    最近更新 更多