03-数据类型

## 四.认识数据类型

-------

在python里为了应对不同的业务需求,也把数据分为了不同的类型

- 数值
  - int 整型
  - float浮点型
- 布尔型
  - True真
  - False假
- str字符串
- list列表
- tuple元祖
- set集合
- dict字典

```python
"""
    1.按经验将不同的变量存储不同的类型的数据

    2.验证这些数据到底是什么类型  -- 检测数据类型 -- type(数据)
"""

# int -- 整型
num1 = 1
print(type(num1))

# float -- 浮点型
num2 = 1.1
print(type(num2))

# str -- 字符串,特点:数据都要带引号
a = 'hello word'
print(type(a))

# bool -- 布尔型,通常判断,布尔型有两个取值 True 和 False
b = True
print(type(b))

# list -- 列表
c = [10,20,30]
print(type(c))

# tuple -- 元组
a = (10,20,30)
print(type(a))

# set -- 集合
e = {10,20,30}
print(type(e))

# dict -- 字典 -- 键值对
f = {'name':'Tom','age':'18'}
print(type(f))
```

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值