一、整型
'''
整型:int
状态:等级,身份证号,年龄
'''
level = 10 # level=int(10)
print(level, type(level), id(level))
二、浮点型
'''
浮点型:float
状态:薪资,身高,体重
'''
salary = 3000.03 #salary = float(3000.03)
print(salary, type(salary), id(salary))
三、字符串
'''
字符串:在引号(单引号,双引号,三引号)里定义的一堆字符
状态:描述性内容:名字,性别
'''
gender = 'male' #gender = str('male')
print(gender)
info = "my name is lemon , i'm a teacher"
print(info)
msg = '''
xxxx
yyyy
zzzz
'''
print(msg)
x = 1
y = 2
res = x + y
print(res)
'''
字符串拼接
1.字符串只能字符串之间进行+或者*
2.加号效率低
'''
info1 = 'hello'
info2 = 'world'
info3 = info1 + info2
print(info3)
print(info3*10)
四、列表
'''
列表:在[]内,用逗号隔开,存放多个任意类型的元素
状态:有序存放多个值
'''
info_list = ['egon', 18, 'femal', ['欧德博爱', 'education', 70]]
# info_list = list(['egon', 18, 'femal', ['欧德博爱', 'education', 70]])
print(info_list[3][0])
五、字典
'''
字典类型:定义在花括号内,用逗号分隔,key:value, value可以是任意类型,但是key必须是不可变类型
不可变类型:字符串、数字
状态:存放多个值
'''
info_dict = {
'name': 'egon',
'age': 18,
'sex': 'femal',
'company': ['欧德博爱', 'education', 70]
} # info_dict = dict({.....})
info_dict1 = {
'name': 'egon',
'age': 18,
'sex': 'femal',
'company': {'name': '欧德博爱', 'type': 'education', 'emp_count': 70}
} # info_dict = dict({.....})
print(info_dict, type(info_dict), id(info_dict))
print(info_dict['sex'])
print(info_dict['company'][2])
print(info_dict1['company']['type'])
六、布尔类型
'''
布尔类型:True, False
状态:用来做逻辑运算的判断
'''
print(type(True))
age = 38
print(age > 18)
输出结果:
![](https://img2020.cnblogs.com/blog/1450179/202006/1450179-20200603205912801-1879383934.png)