#第二种:使用遍历
list3 = [1,1,1,4,4,5,5,7,7,7,7,7,9,9]
list4=[]#创建空的列表
for i in list3:#使用for in遍历出列表
if not i in list4:#将遍历好的数字存储到控的列表中,因为使用了if not ,只有为空的的字符才会存里面,如果llist4里面已经有了,则不会存进去,这就起到了去除重复的效果!!
list4.append(i)#把i存入新的列表中
print(list4)
#第二种:使用遍历
list3 = [1,1,1,4,4,5,5,7,7,7,7,7,9,9]
list4=[]#创建空的列表
for i in list3:#使用for in遍历出列表
if not i in list4:#将遍历好的数字存储到控的列表中,因为使用了if not ,只有为空的的字符才会存里面,如果llist4里面已经有了,则不会存进去,这就起到了去除重复的效果!!
list4.append(i)#把i存入新的列表中
print(list4)
上一篇:python相关性单选题
下一篇:mongodb 朱聪同步
Python中的容器可以解释为:一个包含多个数据项的实体。容器数据类型也称为复合数据类型。
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M