出错 :
一 原因 :
(不看没关系,直接跳过看二解决方案)**
TypeError: ‘NoneType’ object is not iterable 这个错误提示一般发生在将None赋给多个值时。
def myprocess():
a == b
if a != b:
return True, value;
flag, val = myprocess()
在判断语句中,当if条件不满足,并且没有else语句时,函数默认返回None。
在没有return语句时,python也默认会返回None
调用时,将None赋给多个值时,会出现提示:TypeError: ‘NoneType’ object is not iterable
本例中,flag和val都被赋予了None(因为if条件不满足,所以默认返回None)就出现了这样的错误提示。
所以函数返回值一定要考虑到条件分支的覆盖
举例说明:
def contain():
score = 4
if score in num:
return True,score;
num = [1,2,3,0]
iscontain,score = contain()
print iscontain,score
结果
>>>
Traceback (most recent call last):
File "D:\Program Files\python\chengxu\temp.py", line 8, in <module>
iscontain,score = contain()
TypeError: 'NoneType' object is not iterable</span>
>>>
说明:当只有if条件并返回多个变量时,如果if条件不满足会出现异常
解决方法:加上else语句
def contain():
score = 4
if score in num:
return True,score;
else:
return False,score;
num = [1,2,3,0]
iscontain,score = contain()
print iscontain,score
结果
>>>
False 4
注:原因找到,但根据错误提示找到文件,但不知道怎么改。
故采用如下方法
二 解决方案
conda update anaconda-navigator
接着按提示输入y
anaconda-navigator --reset
conda update anaconda-client
接着按提示输入y
conda update -f anaconda-client
接着按提示输入y
最后输入anaconda-navigator
就能打开了
该方法转载自该链接