如何在获取了数据类型后对类型进行进行判断
下面那么写IDLE报错了{:10_266:}type(8) == <class 'int'>
<SyntaxError: invalid syntax> type(8) == int 实际工作中常用isinstance判断类型:
>>> isinstance('wu', str)
True
>>> isinstance('wu', int)
False
>>> isinstance(1, int)
True
>>> isinstance(1.1, int)
False
>>> isinstance('fishc', str)
True
>>> isinstance(1, str)
False
>>> isinstance(1.1, float)
True
>>> isinstance('fishc', float)
False
>>> isinstance(, list)
True
>>> isinstance({1:1,2:2}, dict)
True
>>> 谢谢了{:5_108:}
页:
[1]