Python的List<
列表类似于C/C++中的数组,不同的是数组保存的同一种类型,而列表可以保存不同类型。
列表的增删改查:
name = ['ha', 'hi', 'he']
name.append('hh')将'hh'加入到列表的末尾。
name.insert(下标位置,添加内容)
names.extend(name)将name元组中的内容追加到names元组中。
extend是追加,append是将添加内容当作一个元组加到末尾。
------------------------------------------------------------------------------------
name.pop()将末尾元素删除。
name.remove(str)删除str的一个元素。
del name[下标]下标可以与切片一样的x:y一段区间进行删除。
-------------------------------------------------------------------------------------
name[下标] = 'hello'
使用赋值操作符=进行修改
-------------------------------------------------------------------------------------
in用来查找元素是否存在于列表
'hh' in name
>
Python的字典<
map = {key:value,.... }
添加:map['student'] = 1
删除:del map['student']
修改:map['student'] = new_value
查询:map.get('student') 获取value
>