【问题标题】:Python's version of PHP's time() functionPHP 的 time() 函数的 Python 版本
【发布时间】:2010-10-04 11:32:22
【问题描述】:

我查看了Python Time module,但找不到任何能给出自 1970 年以来多少秒的整数的东西,就像 PHP 对 time() 所做的那样。

我只是在这里遗漏了一些东西,还是有一种常见的方法来做到这一点,而那里根本没有列出来?

【问题讨论】:

    标签: python time


    【解决方案1】:
    import time
    print int(time.time())
    

    【讨论】:

      【解决方案2】:

      time.time() 做到了,但它可能是 float 而不是我假设你期望的 int。也就是说,在某些系统上精度可以高于 1 秒。

      【讨论】:

        【解决方案3】:

        我推荐阅读"Date and Time Representation in Python"。我觉得它很有启发性。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-06-19
          • 2021-10-02
          • 1970-01-01
          • 1970-01-01
          • 2014-08-31
          • 2013-04-17
          相关资源
          最近更新 更多