1.my_list= ['python', 12, 'AB']
python里面没有数组,但是引入了功能更为强大的list,list里面可以装不同类型的东西,比如字符串、字母、数字,除了数字,其他的都用单引号括起来
2.使用len()函数,能得知Listl里面有多少items
len(my_list)
3.
4.使用append()函数 在list后面增加item
# Append
list1.append('append me!')
使用pop()函数把List索引位置为0的item给删除
# Pop off the 0 indexed item
list1.pop(0)
如果是pop()里面没有写元素,默认把list最后一个item给删掉,同时,利用下面的语句可以显示出是什么item被删去了。
也可以使用sort()函数来对List进行按字母表排序
# Use sort to sort the list (in this case alphabetical order, but for numbers it will go ascending)
new_list.sort()
这里已知matrix是(1,2,3;4,5,6;7,8,9)
利用row(0) for row in matrix可以获取第一列