Python datetime随机断开 [英] Python datetime randomly breaking
本文介绍了Python datetime随机断开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这不是我第一次发生这种情况,所以现在我正在寻找一个答案,因为我完全失败了。
This isn't the first time this has happened to me so now I'm looking for an answer because I'm completely stumped.
我有代码运行在一个生产环境超过3个月的时间里,它的工作完全正常,然后就没有我在python开始得到错误。
I have code running in a production environment for over 3 months now and it worked absolutely fine, then out of no where I started to get errors in python.
'method_descriptor' object has no attribute 'today'
Exception Value:
'method_descriptor' object has no attribute 'today'
Exception Location: /admin/views/create.py in process, line 114
/admin/views/create.py in process
order = Orders(uid=0, accepted=0, canview='', files=0, date=datetime.date.today(), due=dueDate,
正如你所看到的, m使用以下从python shell工作绝对罚款:
As you can see, I'm using the following which works absolutely fine from the python shell:
>>> import datetime
>>> datetime.date.today()
>>> datetime.date(2011, 9, 27)
推荐答案
您的代码在某个地方导入 datetime.datetime
,而不是 datetime
,例如 from datetime import datetime
。
Your code is importing datetime.datetime
somewhere, instead of just datetime
, e.g. from datetime import datetime
.
>>> import datetime
>>> datetime.datetime.date.today()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'method_descriptor' object has no attribute 'today'
这篇关于Python datetime随机断开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文