1.python常用的列表操作语法
- 查看某个列表nums中指定元素出现的次数:nums.count(ele)
- 查看一个指定元素的下标:nums.index(ele,start,end)
nums = [1,2,3,4,4] print(nums.count(4))#2 print(nums.index(4,4) //list.index(element, start, end) //element - the element to be searched //start (optional) - start searching from this index //end (optional) - search the element up to this index
2.数组和列表的区别(待填待查)
Python中的list是Python的内置数据类型,list中的数据类型不必相同的;而array中的类型必须是全部相同的。在list中数据类型保存的是数据的存放的地址,简单的说就是指针,并非数据,这样保存一个list就太麻烦了;numpy中封装的array有很强大的功能,里面存放的都是相同的数据类型。



