zoukankan      html  css  js  c++  java
  • Python day17 模块介绍1(time,random)

    module模块和包的介绍(略掉了)

    常用模块

    # time模块
    import time
    
    print(time.time())#时间戳,在1970年开始到现在一共多少秒
    print(time.gmtime())#结构化时间
    print(time.localtime())#当地时间,可传入时间戳转化为结构化时间
    
    print(time.mktime(time.localtime()))#将结构化时间转化为时间戳
    print(time.strftime("%Y-%m-%d %X",time.localtime()))#结构化转换时间,%X是时分秒
    print(time.strptime("2018-8-2 0:18:00","%Y-%m-%d %X"))#字符串时间转化为结构化时间
    print(time.asctime())#结构化时间转化为固定字符串表达形式
    print(time.ctime())#时间戳转化为固定字符串表达形式
    time.sleep(1)#等待
    #random模块
    import random
    
    print(random.random())#生成[0,1)的随机数
    print(random.randint(1,3))
    print(random.randrange(1,3))
    print(random.choice([0,1,2,3,4,5,6]))
    print(random.sample([1,2,3,4,5],3))#选n个
    print(random.uniform(1,3))#任意范围浮点型
    ret=[1,2,3,4,5]
    random.shuffle(ret)
    print(ret)
  • 相关阅读:
    pandas.DataFrame.to_excel
    python list [:1]
    python 读取文件
    pandas 中的常用数学计算
    神经网络相关术语
    keras初探
    机器学习相关
    Numpy random arange zeros
    numpy 常用函数
    【Redis学习之四】Redis数据类型 string
  • 原文地址:https://www.cnblogs.com/littlepage/p/9404343.html
Copyright © 2011-2022 走看看