This is to record some functions and attributes of Python I used before.
the length of list:len(list)
the type of list:type(…)
How to get the index of 'bar'?
["foo", "bar", "baz"].index("bar”)
How to find all indices of a repeated elements?
(找出多个元素所有的index位置)
[i for i, v in enumerate(resIndexList) if v==index]
Iteration
for i in range (0,len(list)):
print i ,list[i]
# enumerate, get index and text info at the same time
for index,text in enumerate(list)):
print index ,text
Remove repeated elements
set(list)
list intersection, union, subset
http://www.yihaomen.com/article/python/323.htm