python基础知识
以python3为主
语法
在 Python 中,变量就是变量,它没有类型,我们所说的"类型"是变量所指的内存中对象的类型,Python 3 中有六个标准的数据类型:
Numbers(数字): int(整型)、float(浮点型)、bool(布尔型)、complex(复数)
·String(字符串)
·List(列表)
·Tuple(元组)
·Sets(集合)
·Dictionaries(字典)
a, b, c, d = 20, 5.5, True, 4+3j
print(type(a), type(b), type(c), type(d))
<class 'int'><class 'float'><class 'bool'><class 'complex'>
类型判断
isinstance(a,int)
看a是否为int,是返回true
- type()不会认为子类是一种父类类型。
- isinstance()会认为子类是一种父类类型。