Python typeError: isinstance() arg 2 必须是一个类型或类型的元组 >>>
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14681096/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
typeError: isinstance() arg 2 must be a type or tuple of types >>>
提问by Monkey2code
>>> names=['jill','Hyman']
>>> 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
>>>
Am I missing something here?
我在这里错过了什么吗?
采纳答案by Ignacio Vazquez-Abrams
You've stomped on listby assigning to a local variable of the same name. Don't do that.
您已经list通过分配给同名的局部变量来踩踏。不要那样做。
回答by Siva Kumar
Apply this one :
应用这个:
if isinstance(names, type(list)):
回答by Keelung
But this works in Python (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32:
但这适用于 Python (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32:
>>> names=['jill', 'Hyman']
>>> isinstance(names, list)
True

