zoukankan      html  css  js  c++  java
  • 6月5日内置模块复习

    time模块

    time.scrftime("%Y-%m-%d  %X") #格式化时间

    time.localtime       #当地时间

    datetime模块

    datetime.datetime.now() #当前时间格式化输出

    random 模块

    random.random()# 0到1之间的小数

    random.randint(1,5) #1到5之间的整数

    random.choice([1,2,[3,4,7],1000])#里面元素选一个

    random.uniform(1,3)#1到3之间的小数 

    random.shuffle(item)#打乱里面元素,洗牌

    os模块

    os.path.normpath  #规范化路径,把斜杠转化为自适应

    os.rename("a.text","b.text")#修改文件名

    os.remove()#去除文件

    os.mkdir()#创建文件夹

    os.path.getsize #获取文件大小

    os.listdir() #列表文件名

    os.path.isdir() #是否存在 文件夹

    os.path.isfile()#是否存在文件

    os.path.exists()#是否存在文件

    os.system("")  里面写要执行的系统命令 

    sys模块

    sys.argv[0] #命令行参数list   第一个元素是程序本身的路径

    sys.version #版本信息

    string模块

    string.count("hello word",l) #等于3

    string.center("hello word",20,"*" )#以center为中心20个字节,不够以*来填充

    string.find("l")找到索引值

  • 相关阅读:
    mobile app 的总结
    ie和火狐javascript区别
    zepto源码注释
    ie6bug
    html5游戏网站
    jquery作者封装函数
    vue element 动态表格
    uniapp 对 系统的控制,全屏,系统虚拟键盘,手机导航,强制横屏
    环形图表记录
    清除所有的滚动条
  • 原文地址:https://www.cnblogs.com/zhaoweihang/p/9141656.html
Copyright © 2011-2022 走看看