目录标题
数据类型
编程语言基本上都是有自己的数据类型而且大同小异
直接上图让你更清晰更直观的看到python的数据类型
可以通过type来判断数据类型
type可以判断我定义的第一个变量的数据类型在Pycharm中run执行代码后不会返回内容只是显示执行完毕
需要用print打印出type判断后的结果
#int 整型
num1 = 1
#float 浮点型,就是小数
num2 = 1.1
print(type(num1))
print(type(num2))
#str 字符串,数据都要带引号单双都一样
a = 'hellword'
print(type(a))
#bool 布尔型,判断时使用,分别为True 和 False 代表真和假
b = True
print(type(b))
#list 列表
c = [10, 20, 30]
print(type(c))
#tuple 元组
d = (10, 20, 30)
print(type(d))
#set 集合
e= {10, 20, 30}
print(type(e))
#dict 字典 键值对的形式,一个键有一个值逗号隔开
f= {'name':'Chen','age':18}
print(type(f))
以上均时各种数据类型的语法均可以判断出来