易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 170|回复: 1
收起左侧

AttributeError: type object 'datetime' has no attribute 'datetime'

[复制链接]
发表于 2025-4-28 21:18:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
AttributeError: type object 'datetime' has no attribute 'datetime'! K2 S5 |, ~- x8 W% H2 @3 G, W

6 V7 v- y8 f/ r: e/ Y
: L- j+ g/ F4 q5 n% d1 f2 B# |AttributeError: type object 'datetime' has no attribute 'datetime'
, @' @5 q8 `$ n/ a  M[28/Apr/2025 21:12:45] "GET /hello/test/filter/ HTTP/1.1" 500 69413
) e2 i4 z' M6 r! NInternal Server Error: /hello/test/filter/
5 E! k  d7 t' C5 H6 P$ fTraceback (most recent call last):( A3 b( z+ A! }( M# F
  File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
2 q6 [. P3 o: b0 _, z4 h* }    response = get_response(request)& e: B! ~# o+ F  p% a
  File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response: h6 c3 y% V7 C* e+ r2 e* g
    response = self.process_exception_by_middleware(e, request)
  E/ A& A) ~' G, F3 Z; b; S  File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response3 t8 ^0 y3 `/ `( ?0 R, a  T$ d
    response = wrapped_callback(request, *callback_args, **callback_kwargs). {8 j3 U8 N) y/ q; ?0 C
  File "C:\Users\admin\Desktop\testmyproject\hello\views.py", line 160, in test_filter
0 `+ l2 v$ |* C1 F    my_date = datetime.datetime(2050, 9, 28)
8 `& M: @/ }5 T6 YAttributeError: type object 'datetime' has no attribute 'datetime'$ l6 V" D+ n' R- \' i7 @# l: w
, k8 n; a8 n5 O: b
0 q  u" Z6 }, ^$ u
7 |1 M! `6 }) [, t+ _
 楼主| 发表于 2025-4-28 21:23:11 | 显示全部楼层
解决办法:
" c2 s) m* b8 X: T" ]( F0 K调整引入时间的参数:
+ U4 n6 N0 O4 h' P: ^from datetime import datetime    这个参数不可以成功,
$ ]5 }7 m$ R+ I7 R9 G7 Aimport datetime    引入这个参数即可正常获取时间。
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 20:24 , Processed in 0.047448 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

快速回复 返回顶部 返回列表