【python】TypeError NoneType object is not subscriptable

‘NoneType’ object is not subscriptable

出错的位置:

if thickness[0] is None:
    print ("cannot estimate the slice thickness!")

错误原因是:我本来想得到的thickness是个list,但因为某些原因查看发现计算得到的thickness是None,所以它无所谓索引,没有None[0]。
改正:

if thickness is None:
    print ("cannot estimate the slice thickness!")

你可能感兴趣的:(【python】TypeError NoneType object is not subscriptable)