NoneType对象Python

while curr!= None: i = curr.next x = x + 1 print(x) if(i.next == None and x/2==0): some statements

当我运行此代码时,它给我一个NoneType对象错误。但是当我运行这段代码

while curr!= None: i = curr.next x = x + 1 print(x) if(i.next == None):

无需检查其他条件即可正常运行。有人可以解释为什么会这样吗,我该如何处理?

评论