python timedate 相关 bug

今天遇到好多个关于datetime的报错,于是有了一个想法,把datetime相关的bug都记录下来。

1、method_descriptor object has no attribute today

解决:导入模块写的是from datetime import datetime,改成import datetime

2、descriptor strftime requires a datetime.date object but received a str

问题:strftime函数用错了,原来的代码是strftime("%y%m", datetime.date object)

解决:把strftime函数里的参数对调一下,即strftime(datetime.date object,"%y%m" )

发布了34 篇原创文章 · 获赞 4 · 访问量 3351

猜你喜欢

转载自blog.csdn.net/lvhuike/article/details/104838008