四、Python数据类型
4.1、Python内置数据类型
- 整型:int
- 浮点型:float
- 布尔类型:bool
- 字符串:str
- 二进制类型:bytes、bytearray
- 复数:complex
- 列表:list
- 元组:tuple
- 字典:dict
a = 100 # 整型
print(type(a))
a = 100.0 # 浮点型
print(type(a))
a = True # 布尔类型
print(type(a))
a = '12345' # 字符串类型
print(type(a))
a = b'\x01\x02\x03\x04\x05\x06\x07\x08' # 二进制类型
print(type(a))
a = 5 + 2j # 复数
print(type(a))
a = [1, 2, 3, '123'] # 列表
print(type(a))
a = (1, 2, 3, '123') #元组
print(type(a))
a = {
"A1":"B1","A2":"B2","A3":"B3"} # 字典
print(type(a))
输出:
<class 'int'>
<class 'float'>
<class