One,. List:
1. The sequence is the most basic data structure in Python. Each element in the sequence is assigned a number-its position, or index, the first index is 0, the second index is 1, and so on.
Cities=[]
Increase
Cities.append (' Beijing ')#在列表末尾增加一个元素
Cities.insert (0, ' Shanghai ')#在指定位置增加元素
Delete
Cities.pop (0)#删除指定位置的元素
Cities.remove (' Beijing ')#删除指定的元素
Cities.clear () #清除list
Del.cities[-1]#删除指定位置的
Modify
Print (cities)
cities[1]= ' Nanjing '#修改的时候如果指定的下标不存在, will be error
Check
Print (Cities[0])#查指定位置的
Print (Cities.index (' Guangzhou '))#获取元素的下标, if you can't find that element, you will get an error .
Print (Cities.count (' Guangzhou '))#产看元素在list里边出现了多少次
My_list = [' Python ', ' jmeter ', ' Charles ', ' Postman ']
Print (My_list.reverse ())#把这个list反转一下
Nums = [9,2,34,12,34,457,2342]
Nums = [' B ', ' f ', ' e ', ' Z ', ' g ', ' H ']
Nums.sort ()#升序排列
Nums.sort (reverse=true) #降序排列
Print (cities+cities2)#合并list
Print (cities*3)#复制几次
words = [' view ', ' Code ', ' Tools ', [' Price ', ' num ', 198,[' hello ', ' USA ', ' eat chicken ']] #二维数组
Print (words[-1][-1][1])
Print (words[-1][2])
Python Automation third Day-python