首页
Python
Java
IOS
Andorid
NodeJS
JavaScript
HTML5
【
2017-12-19python全栈9期第四天第二节之列表的增删改查之切片
】的更多相关文章
2017-12-19python全栈9期第四天第二节之列表的增删改查之切片
#!/user/bin/python# -*- coding:utf-8 -*-li = ['zd',[1,3,4,5,6],'ls','ww','zl']l1 = li[0]print(l1)l2 = li[1]print(l2)l3 = li[0:3]print(l3) #切片顾头不顾尾…
2017-12-19python全栈9期第四天第二节之列表的增删查改之元祖是只读列表、可循环查询、可切片、儿子不能改、孙子可以改
#!/user/bin/python# -*- coding:utf-8 -*-tu = ('zs','ls','ww',[1,2,3,4,5,'zxcvb'],'zl')print(tu[3])print(tu[0:4])for i in tu: print(i)tu[3][5] = tu[3][5].upper()print(tu)tu[3].append('fdsfds')print(tu)…
2017-12-19python全栈9期第四天第二节之列表的增删查改之正向排序和倒向排序和反转
#!/user/bin/python# -*- coding:utf-8 -*-li = [3,5,6546,6,8,324,2,1,34,5,6,7]# li.sort() #正向# print(li)# li.sort(reverse=True) #倒向# print(li)li.reverse()print(li)…
2017-12-19python全栈9期第四天第二节之列表的增删查改之公共方法len和count和index
#!/user/bin/python# -*- coding:utf-8 -*-li = ['zs','ls','ww','zl','xx']l = len(li) #总数print(l)num = li.count('ww') #计数几个print(num)print(li.index('zl')) #索引位置#li =…
2017-12-19python全栈9期第四天第二节之列表的增删查改之按索引改和按切片改
#!/user/bin/python# -*- coding:utf-8 -*-li = ['zs','ls','ww','zl','xx']li[0] = 'cxvb' #按索引位置print(li)li[0:3] = 'vcxzvcxz' #切片改print(li)…
2017-12-19python全栈9期第四天第二节之列表的增删查改之按切片删除
#!/user/bin/python# -*- coding:utf-8 -*-li = ['zs','ls','ww','zl','xx']# del li[1:] #1到最后# print(li)del li[0:3] #顾头不顾尾print(li)…
2017-12-19python全栈9期第四天第二节之列表的增删查改之删除的pop和del和remove和clear
#!/user/bin/python# -*- coding:utf-8 -*-li = ['zs','ls','ww','zl']# name = li.pop(1) #按索引位置删除有返回值# name1 = li.pop()#默认删除最后一个有返回值# print(name,name1,li)# li.remove('ls') #按指定位置删除# print(li)li.clear() #清空print(li)# del li# print(li)…
2017-12-20python全栈9期第五天第二节之字典的增删查改和字典的for循环
#!/user/bin/python# -*- coding:utf-8 -*-dic1 = {'age':24,'name':'zd','sex':'boy'}print(dic1)#增dic1['high'] = 175 #没有建就添加dic1['sex'] = 'boy1' #有建就修改print(dic1)dic1.setdefault('weight',232) #有的话不做任何操作m没有的话就添加print(dic1)#删print(dic1.pop('age'))#有返回值按键去删…
2017-12-20python全栈9期第五天第二节之可变 数据类型和不可变数据类型
…
2017-12-19python全栈9期第四天第一节之昨日内容回顾与作业讲解之插入insert和extend
#!/user/bin/python# -*- coding:utf-8 -*-li = ['zs','ls','ww','zl']li.insert(4,'cc')print(li)li.extend('pl')li.extend([1,3,4,5])print(li)print(li)…