一、整型
py2:数据过长的用long | 数据量小的用int存储
py3:pyhon中只有用int存储数据,数据量大的,内部用字符串存储,并可以直接进行运算
二、浮点型
float:用来存放小数
salary=111111.22222
三、布尔值
bool类型:True and Flase
四、字符串
五、列表
六、字典
dic = {‘key‘: ‘value‘}
‘‘‘
people = {
‘name‘: ‘Liuxx‘,
‘age‘: 68,
‘gender‘: ‘哇塞‘
}
print(people)
print(people[‘age‘])
info = {
‘name‘: ‘egon‘,
‘hobbies‘: [‘play‘, ‘sleep‘],
‘company_info‘: {
‘name‘: ‘Oldboy‘,
‘type‘: ‘education‘,
‘emp_num‘: 40,
}
}
res = info[‘company_info‘][‘emp_num‘]
print(res)
res = info[‘hobbies‘][1]
print(res)
students=[
{‘name‘:‘alex‘,‘age‘:38,‘hobbies‘:[‘play‘,‘sleep‘]},
{‘name‘:‘egon‘,‘age‘:18,‘hobbies‘:[‘read‘,‘sleep‘]},
{‘name‘:‘wupeiqi‘,‘age‘:58,‘hobbies‘:[‘music‘,‘read‘,‘sleep‘]},
]
print(students[1][‘hobbies‘][0])
原文:https://www.cnblogs.com/chuwanliu/p/10713286.html