推荐学习书目
› 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
datou
V2EX  ›  Python

求助 Python 有什么库可以快捷的转换时间到类似 ISODate"2018-06-21T07:57:04.229Z"这样的格式

  •  
  •   datou · Jul 10, 2018 · 4479 views
    This topic created in 3040 days ago, the information mentioned may be changed or developed.
    2 replies  •  2018-07-10 15:59:04 +08:00
    NobodyVe2x
    NobodyVe2x
    Jul 10, 2018
    1
    参考:
    #'Thu Mar 31 17:31:45 CST 2016' => 20160331173145
    def convertdatastring(dstr):
    timestamp = time.mktime(time.strptime(dstr, '%a %b %d %H:%M:%S CST %Y'))
    result = datetime.datetime.fromtimestamp(int(timestamp)).strftime('%Y%m%d%H%M%S')
    return result

    如果是反过来,直接 format 格式化啊!
    welkinzh
    welkinzh
    Jul 10, 2018
    2
    datetime.datetime.now().isoformat()
    是这样吗
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3476 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 05:14 · PVG 13:14 · LAX 21:14 · JFK 00:14
    ♥ Do have faith in what you're doing.