关于module ‘datetime‘ has no attribute ‘now‘报错解决方案

Posted 是璇子鸭

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于module ‘datetime‘ has no attribute ‘now‘报错解决方案相关的知识,希望对你有一定的参考价值。

原代码:

import datetime
print(datetime.now())

在这里插入图片描述
思路一(datetime.datetime):

import datetime

print(datetime.datetime.now())

运行成功

2021-07-10 14:56:15.941761

思路二 修改文件名

如果在添加datetime后还是无情报错,则可能是因为当前文件夹里含有datetime.py文件,覆盖了datetime 模块。修改下文件名就好了❤
在这里插入图片描述

以上是关于关于module ‘datetime‘ has no attribute ‘now‘报错解决方案的主要内容,如果未能解决你的问题,请参考以下文章

关于py的AttributeError: module 'XXX' has no attribute 'XXX'问题

关于*[pylint]E1101:Module 'xxx' has no 'xxx' member* 简单而有效的解决办法

突然的 Tensorflow / Keras Google Colab 依赖问题`AttributeError: module 'tensorflow._api.v1.compat.v2' has n

module ‘ffmpeg‘ has no attribute ‘probe‘

module ‘ffmpeg‘ has no attribute ‘probe‘

解决module ‘tensorflow‘ has no attribute ‘...‘系列