Python GuidLine(python编程规范) PEP8

Python Enhancement Proposals (PEP)

https://www.python.org/dev/peps/pep-0008/

https://legacy.python.org/dev/peps/

python API

https://www.runoob.com/python3/python3-att-list-append.html

python解包*   ** 

* 用来解封列表或元组

** 用来解封字典

https://www.cnblogs.com/lmh001/p/9960300.html

python中的iterable如何理解

https://www.jianshu.com/p/6b7806c4f54a

python zip函数

https://www.runoob.com/python/python-func-zip.html

Python zip() 函数 //输入参数为元组或列表 返回值为含有元组的列表

python如何返回多个值,返回的是元组即可,zip返回的是元组的列表,所以可以返回多个值分别就代表了元组

https://www.cnblogs.com/baxianhua/p/10755137.html

Python 内置函数 Python 内置函数


描述

zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表。

如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,利用 * 号操作符,可以将元组解压为列表。

zip 方法在 Python 2 和 Python 3 中的不同:在 Python 3.x 中为了减少内存,zip() 返回的是一个对象。如需展示列表,需手动 list() 转换。

如果需要了解 Pyhton3 的应用,可以参考 Python3 zip()

语法

zip 语法:

zip([iterable, ...])

参数说明:

  • iterabl -- 一个或多个迭代器;

返回值

返回元组列表。

实例

以下实例展示了 zip 的使用方法:

>>>a = [1,2,3] >>> b = [4,5,6] >>> c = [4,5,6,7,8] >>> zipped = zip(a,b) # 打包为元组的列表 [(1, 4), (2, 5), (3, 6)] >>> zip(a,c) # 元素个数与最短的列表一致 [(1, 4), (2, 5), (3, 6)] >>> zip(*zipped) # 与 zip 相反,*zipped 可理解为解压,返回二维矩阵式 [(1, 2, 3), (4, 5, 6)]

Python 内置函数 Python 内置函数

 Python OS 文件/目录方法

Python 面向对象 

 

2 篇笔记 写笔记

  1.    旭日再现

      xsx***[email protected]

    55

    列表元素依次相连:

    # -*- coding: UTF-8 -*-
    
    l = ['a', 'b', 'c', 'd', 'e','f']
    print l
    
    #打印列表
    print zip(l[:-1],l[1:])

    输出结果:

    ['a', 'b', 'c', 'd', 'e', 'f']
    [('a', 'b'), ('b', 'c'), ('c', 'd'), ('d', 'e'), ('e', 'f')]
    旭日再现

       旭日再现

      xsx***[email protected]

    2年前 (2018-03-13)
  2.    送院途中

      135***[email protected]

    50

    nums = ['flower','flow','flight']
    for i in zip(*nums):
        print(i)

    输出结果:

    ('f', 'f', 'f')
    ('l', 'l', 'l')
    ('o', 'o', 'i')
    ('w', 'w', 'g')

Python3 List append()方法

Python3 列表 Python3 列表


描述

append() 方法用于在列表末尾添加新的对象。

语法

append()方法语法:

list.append(obj)

参数

  • obj -- 添加到列表末尾的对象。

返回值

该方法无返回值,但是会修改原来的列表。

terrific 英[təˈrɪfɪk] 美[təˈrɪfɪk]
adj. 极好的; 绝妙的; 了不起的; 很大的; 巨大的; 异乎寻常的;

[例句]What a terrific idea!

多么好的主意!

python map()函数

https://www.runoob.com/python/python-func-map.html

Python map() 函数

Python 内置函数 Python 内置函数


描述

map() 会根据提供的函数对指定序列做映射。

第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。

语法

map() 函数语法:

map(function, iterable, ...)

参数

  • function -- 函数
  • iterable -- 一个或多个序列

返回值

Python 2.x 返回列表。

Python 3.x 返回迭代器。

实例

以下实例展示了 map() 的使用方法:

>>>def square(x) : # 计算平方数 ... return x ** 2 ... >>> map(square, [1,2,3,4,5]) # 计算列表各个元素的平方 [1, 4, 9, 16, 25] >>> map(lambda x: x ** 2, [1, 2, 3, 4, 5]) # 使用 lambda 匿名函数 [1, 4, 9, 16, 25] # 提供了两个列表,对相同位置的列表数据进行相加 >>> map(lambda x, y: x + y, [1, 3, 5, 7, 9], [2, 4, 6, 8, 10]) [3, 7, 11, 15, 19]

Python 内置函数 Python 内置函数

发布了85 篇原创文章 · 获赞 78 · 访问量 159万+

猜你喜欢

转载自blog.csdn.net/studyvcmfc/article/details/103852621