zoukankan      html  css  js  c++  java
  • 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

    将模块路径写在里面

  • 相关阅读:
    扯一扯纯函数
    10.28
    10.27 动手动脑5
    10.26
    10.25 周总结
    10.23
    10.22
    10.21 动手动脑4
    10.20
    10.19
  • 原文地址:https://www.cnblogs.com/goodspeed/p/2230542.html
Copyright © 2011-2022 走看看