Goodspeed

导航

python小技巧汇总

# -*- coding: UTF-8 -*-
#
!/usr/bin/env python
def pairwise(iterable):
"""
交叉形成字典
"""
itnext = iter(iterable).next
while True:
yield itnext(),itnext()

def distinct(seq):
"""
对序列进行去重
"""
return dict.fromkeys(L).keys()

if __name__ == '__main__':
L = ["abc","123","def","456"]
print dict(pairwise(L))
L = ["abc","123","abc","456"]
print distinct(L)

增加模块的搜索路径

windows

在C:\Python27\Lib\site-packages下新加一个x.pth

将模块路径写在里面

posted on 2011-10-31 17:37  Goodspeed  阅读(382)  评论(0编辑  收藏  举报