类型错误:isinstance() 的第二个参数必须是类型或类型元组 >>>
>>> names=['jill','jack']
>>> isinstance(names,list)
Traceback (most recent call last):
File "<pyshell#291>", line 1, in <module>
isinstance(names,list)
TypeError: isinstance() arg 2 must be a type or tuple of types
>>>
我是不是漏掉了什么?
6 个回答
8
但是这个在Python(版本3.7.1:260ec2c36a,2018年10月20日,14:05:16)[MSC v.1915 32位(英特尔)]的win32系统上是可以运行的:
>>> names=['jill', 'jack']
>>> isinstance(names, list)
True
21
使用这个:
if isinstance(names, type([])):
71
你把 list
给覆盖了,因为你用一个同样名字的局部变量去赋值了。别这么做。