1.与List有关的操作
1.1List去重
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
1.2List删除指定元素
str=[1,2,3,4,5,2,6]
str.remove(2)
2.参数返回
import math
def move(x, y, step, angle=0):
nx = x + step * math.cos(angle)
ny = y - step * math.sin(angle)
return nx, ny
x, y = move(100, 100, 60, math.pi / 6)
#事实上返回的是一个tuple