执行数学运算时出现 NoneType 错误
NoneType Error being raised when performing math operation
math.floor(16*((a*tl[i][0]+c)%m/(10**math.floor(math.log10((a*tl[i][0]+c)%m))+1)))
这行代码一直返回异常“'NoneType' object is not subscriptable”,我不确定为什么。将不胜感激。
当您尝试下标(即使用方括号 []
)a None
时会发生该错误。例如:
>>> x = None
>>> x[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not subscriptable
确保 tl
不是 None
并且 tl[i][0]
不是 None
对于所有 i
。
math.floor(16*((a*tl[i][0]+c)%m/(10**math.floor(math.log10((a*tl[i][0]+c)%m))+1)))
这行代码一直返回异常“'NoneType' object is not subscriptable”,我不确定为什么。将不胜感激。
当您尝试下标(即使用方括号 []
)a None
时会发生该错误。例如:
>>> x = None
>>> x[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not subscriptable
确保 tl
不是 None
并且 tl[i][0]
不是 None
对于所有 i
。