python --- 22 初始模块 random time collections functools

一 .初始模块

  1.从⼩到⼤的顺序: ⼀条代码 < 语句块 < 代码块(函数, 类) < 模块

  2.引入模块的方式

    ①   import   模块

    ②   from   模块  import    功能

python --- 22 初始模块 random time collections functools

 

 二.     random模块

python --- 22 初始模块 random time collections functools

三 time 模块

  1.时间戳                 从1970-01-01  00:00:00  开始以 秒  计算

                    东八区  从1970-01-01  08:00:00

      time.time()        用于时间存储   

python --- 22 初始模块 random time collections functools

 

     2.格式化

python --- 22 初始模块 random time collections functools

 

python --- 22 初始模块 random time collections functools

python --- 22 初始模块 random time collections functools

 

  3.结构化(python的时间)

python --- 22 初始模块 random time collections functools

 

   4 转化

python --- 22 初始模块 random time collections functools

python --- 22 初始模块 random time collections functools

四.    collections  模块

  1.counter (可迭代对象)         计数

    每一个元素出现的次数

     获取到的结果可以像字典⼀样进⾏使⽤

  2.defaultdict( lambda:0)   默认值字典

  3.OrderedDict( )    将字典有序化

  4.数据结构( 栈   队列)

    ①栈:  先进后出

python --- 22 初始模块 random time collections functools

python --- 22 初始模块 random time collections functools

 

      ②队列: 先进先出

python --- 22 初始模块 random time collections functools

    ③双向

python --- 22 初始模块 random time collections functools

五.namedtuple    命名元组

    类似创建一个类

面向对象:

python --- 22 初始模块 random time collections functools

命名元组:

python --- 22 初始模块 random time collections functools

 

六.functools  模块

  1.wraps    (装饰器中)  可以改变一个函数的名字 ,注释

python --- 22 初始模块 random time collections functools

 

   2.reduce    归纳   

python --- 22 初始模块 random time collections functools

 

  3.partial    偏函数  固定函数中的参数

      新函数 = (旧参数,固定值)

python --- 22 初始模块 random time collections functools