python3.x - Python3.4 datetime.today() and datetime.now() 有什么区别

 杰ZGJ8513 发布于 2022-11-01 08:59
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.today()
datetime.datetime(2015, 8, 30, 23, 17, 6, 937659)
>>> datetime.datetime.now()
datetime.datetime(2015, 8, 30, 23, 17, 14, 378097)
>>>

看上去似乎没区别啊

2 个回答
  • https://docs.python.org/3.4/library/datetime.html?highlight=datetime#module-datetime

    classmethod datetime.now(tz=None)
    Return the current local date and time. If optional argument tz is None or not
    specified, this is like today()

    这英语貌似不难。

    2022-11-01 22:36 回答
  • 这种时候请读文档

    now()接收一个参数tz,也就是timezone时区,如果这个参数不存在时,它的表现等同于today()

    2022-11-01 22:38 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有