[英]Python datetime “int object is not callable”
from datetime import datetime, date
now = datetime.now()
print now.day()
How come when this code gives an error "'int' object is no callable", is there even a use to now.day()? 当这段代码给出错误信息“'int'object is not callable”时,为什么现在使用now.day()?
print now.day
is all you need 是你所需要的全部
datetime.day
is a property not a method and it returns the integer day ... so you are trying to call an integer when you add parentheses (ala 28()
, which also clearly would not work) datetime.day
是属性而不是方法,它返回整数day ...,因此您尝试在添加括号时调用整数(ala 28()
,这显然也行不通)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.