摘要: dic = {'a1':'he','a2':'ma','a3':'ye','height':20,'sex':'male'} #把KEY转换成列表,再遍历列表 for key in list(dic.keys()): if 'a' in key: dic.pop(key) print(dic) #创 阅读全文
posted @ 2020-03-27 13:05 河马哥 阅读(262) 评论(0) 推荐(0) 编辑
摘要: #倒序删除 li1=[00,11,22,33,44,55,66,77,88,99] count = len(li1)-1 while count >= 0: if count % 2 != 0: li1.pop(count) count -= 1 print(li1) #切片法 li1=[00,11 阅读全文
posted @ 2020-03-27 12:51 河马哥 阅读(603) 评论(0) 推荐(0) 编辑
摘要: #ID的练习 #1看代码写结果 v1 = [1,2,3,4,5] v2 = [v1,v1,v1] v1.append(6) print(v1) print(v2) #2 v1 = [1,2,3,4,5] v2 = [v1,v1,v1] v2[1][0] = 111 v2[2][0] = 222 pr 阅读全文
posted @ 2020-03-27 12:38 河马哥 阅读(124) 评论(0) 推荐(0) 编辑