1.基本数据类型
1.整数类型 int
1 2 6 10 126 0 6496665
2.字符串类型 str - 凡是用引号引起来的都是字符串
单引号 '字符串'
双引号 "字符串"
三引号 '''字符串''' """字符串 """
3.布尔类型 bool
True 真
False 假
2.变量定义
a = 1 # a是整数类型的变量,其初始值为1
b = '1' #b是字符串类型的变量,其初始值为 '1'
c = True #c是布尔类型的变量,其初始值为True
python中,变量只有在定义且被赋予值后,才可被使用
3.变量类型的互相转换
用python内置函数 type()可以查看变量的所属类型
a = int('1') #type(a) 为int类型, 即a = 1
b = str(1) #type(b) 为str类型, 即b = '1'
c = int(True) #type(c) 为int类型, 且c 的值为1
d = int(False) #type(d) 为int类型, 且d 的值为0