本人正在学Python入门基础,用macos(12.0.1)在使用Python 3(IDLE Shell 3.10.0)使用isinstance函数判断类型,一直报错是什么原因?使用type函数的时候是没问题的。
a = 1
isinstance(a,str)
Traceback (most recent call last):
File "<pyshell#122>", line 1, in <module>
isinstance(a,str)
TypeError: 'tuple' object is not callable
isinstance(a,int)
Traceback (most recent call last):
File "<pyshell#123>", line 1, in <module>
isinstance(a,int)
TypeError: 'tuple' object is not callable
type(a)
<class 'int'>
a = 'hello'
isinstance(a,str)
Traceback (most recent call last):
File "<pyshell#126>", line 1, in <module>
isinstance(a,str)
TypeError: 'tuple' object is not callable
isinstance(a,int)
Traceback (most recent call last):
File "<pyshell#127>", line 1, in <module>
isinstance(a,int)
TypeError: 'tuple' object is not callable
type(a)
<class 'str'>
我已经检查过很多次,输入法,标点符号,空格都是对应的也是在英文输入法下输入的。
请各位指点!
谢谢