列表类型
一、列表
作用
存放多个值
定义
hobby = 'read'
hobby_list = [hobby , 'run' , 'girl']
print(id(hobby_list))
print(type(hobby_list))
print(hpbby_list)
4558605960
<class 'list'>
['read', 'run', 'girl']
用法
hooby_list = ['read' , 'run' , 'girl']
# 索引序号 0 1 2
# 取出第二个爱好
print(hobby_lsit[1])
run
hobby_list = ['read' , 'run',['girl_name', 18, 'shanghai']]
# 取出girl的年龄
print(hobby_lsit[2][1])
18