我试图将一个时间值存储在一个数组中,但每次都会给我一个错误,即使我尝试将float转换为int也是如此。这里是我的代码的部分:强制转换为int而不能在Python中工作
EndTimes = [0,0,0,0]
...
EndTimes[TakenSlots] = int(time.time() + n)
,但它只是给出了这样的错误:
[error] TypeError (list indices must be integers)
[error] --- Traceback --- error source first
line: module (function) statement
44: main (craftTime) EndTimes[TakenSlots] = tempInt
我想这个代码只是为了看看它认为的价值是:
tempInt = int(time.time() + n)
print tempInt
EndTimes[TakenSlots] = tempInt
它只是输出1412046180(没有小数位,这似乎应该是一个int)
有谁知道w帽子发生了吗?它是int()还是我使用的数组类型的问题?提前致谢!
您能告诉我们完整的代码吗? – 2014-09-30 03:07:08