Python Error - Int Object Has No Attribute
Solution 1:
As time = 3
is declared as an integer,
time.time
doesn't have any sense since time is int
variable (that isn't a class but a primitive data type). I suppose that you expected to call time
(module) writing time
but, since you're redefining it as an integer, this last definition shadows the time
module
Change time
variable name to something else, like myTime
Error messages are usefull, you should read them. Often the answer is contained directly into this errors/warning messages
Solution 2:
You declare time
variable. While time
is module imported from import
statement. So when you access time.x
its try to access variable instead of module
.
Change variable name or import module time
as another name.
Solution 3:
You have variable time:
time = 3
and you have previously imported package time:
import time
When you try to do
time.time()
it seems that you try to call method time() of variable time (that contains int).
You should rename it and it will figure out conflicts with package name.
Post a Comment for "Python Error - Int Object Has No Attribute"