因为还在看书阶段,对很多概念不是太理解,先把这些有疑问的地方记录下来,方便以后学习。
Q1.python中的isinstance()与type(a)==type(b){比较对象的值}以及type(a) is type(b){比较内存地址}有什么关系?
>>> a=3
>>> b=4
>>> type(a)==type(4)
True
>>> type(a) is type(b)
True
>>> print(type(a))
<class 'int'>
>>> print(type(b))
<class 'int'>
>>> id(type(a))
505668504
>>> id(type(b))
505668504
>>> help(a.isinstance())
<span style="color:#ff6666;">Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
help(a.isinstance())
AttributeError: 'int' object has no attribute 'isinstance'</span>
这怎么解决?今天的收获:对python的几种类型进行分类,按照存储,取值,更改三种方式。字符串,数值,元组,列表,字典在于我来说不再是一个个单一的部分,而是交叉联系,帮助我回忆了数据结构里面的知识。