V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ooleslie
V2EX  ›  Python

关于 Python 中的时间请教

  •  
  •   ooleslie · 2019-01-20 01:39:00 +08:00 · 1705 次点击
    这是一个创建于 1916 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近网很卡,想偷懒问下大家几个问题哈:
    - time.time()和 datetime.datetime.timestamp()显示的时间戳为什么不一样?不都是 from epoch time 么?是因为后者加了等待的时间么?
    -在 python 中用哪些函数来记录 wall time, user time 和 cpu time?

    希望 wifi 的频段能分布的开一点,在不远的将来。。。
    4 条回复    2019-01-20 14:13:23 +08:00
    silkriver
        1
    silkriver  
       2019-01-20 08:50:48 +08:00   ❤️ 1
    lrxiao
        2
    lrxiao  
       2019-01-20 11:36:33 +08:00   ❤️ 1
    1. https://github.com/python/cpython/blob/master/Lib/datetime.py#L1588 datetime 做了一次 rounding
    2. wall time: time.time() / cpu time: time.process_time()
    都用 py 了为啥还要 user time kernel time..
    ooleslie
        3
    ooleslie  
    OP
       2019-01-20 14:09:42 +08:00
    @silkriver 谢谢,这篇好像没有深入到 time.time()和 datetime.timestamp 的区别。。。不过,补充了不少别的细节
    ooleslie
        4
    ooleslie  
    OP
       2019-01-20 14:13:23 +08:00
    @silkriver - -尴尬。。这两个没什么大的区别,昨天运行的时候输入的参数有问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   985 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:20 · PVG 04:20 · LAX 13:20 · JFK 16:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.