NULL
博文链接:https://shixm.iteye.com/blog/381884abstract
Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple
but effective approach to ohject-oriented programming. Python's elegant syntax a
测试函数:
第一种:list的set函数
第二种:{}.fromkeys().keys()
测试代码:
#!/usr/bin/python
#-*- coding:utf-8 -*-
import time
import random
l1 = []
leng = 10L
for i in range(0,leng):
temp = random.randint(1,10)
l1.append(temp)
print '测试列表长度为:',leng
#first set
last = ti
今天遇到一个问题,在同事随意的提示下,用了 itertools.groupby 这个函数。不过这个东西最终还是没用上。
问题就是对一个list中的新闻id进行去重,去重之后要保证顺序不变。
直观方法
最简单的思路就是:
复制代码 代码如下:
ids = [1,2,3,3,4,2,3,4,5,6,1]
news_ids = []
for id in ids:
if id not in news_ids:
news_ids.append(id)
print news_ids