zoukankan      html  css  js  c++  java
  • python常用模块2

    os模块
    print(os.getcwd())#取当前工作目录
    print(os.chdir(r"e:yz_codeday2"))#更改当前目录
    print(os.mkdir("test1"))#创建文件夹
    print(os.makedirs(r"test1 est2"))#递归创建文件夹,父目录不存在时创建父目录
    # print(os.removedirs(r"test1 est2"))#递归删除空目录
    # print(os.rmdir("test1"))#删除指定的文件夹,只能删除空文件夹
    print(os.remove(r"E:yz_codeday4a.txt"))#删除文件
    # os.rename("test","test1")#重命名
    # print(os.sep)#当前操作系统的路径分隔符
    print(__file__)#代表当前文件
    print(os.path.abspath('bb.py'))#获取绝对路径
    # print(__file__)#代表当前文件
    # print(os.path.dirname)
    # print(os.path.dirname(os.path.dirname(__file__)))#获取父目录
    # print(os.path.exists("hhaaa"))#目录/文件是否存在
    # print(os.path.isfile("bb.py"))#判断是否是一个文件
    # print(os.path.isdir("/usr/local"))#是否是一个路径
    # print(os.path.join("root",'hehe','haha','a.log'))

    time&datetime模块
    time和datetime模块主要用于操作时间
    时间有三种表示方式,一种是时间戳、一种是格式化时间、一种是时间元组

    re模块
    re模块是正则表达式模块,用来匹配一些特定的字符串。
    常用的正则表达式符号

    常用的匹配语法

     

  • 相关阅读:
    mysql主从同步图
    VS2010智能提示失效,关键字不智能提示!
    mvc3的SaveChanges()方法无效,数据并没有更新!
    使用uploadify上传插件时遇到 NetworkError: 403 Forbidden http://xxxx/xxxx/ 错误
    Asp.net 调用mysql存储过程参数传中文乱码!
    The entity type XXXInfo is not part of the model for the current context.
    爬取汽车网站汽车数据
    《牛顿和莱布尼兹对最速降落线问题的解法,少为人知》 回复
    《谁能证明:标准波面的光若能汇集于一点,则它们的光程长度必然相等》 回复
    200^199 和 199^200 哪个大 ?
  • 原文地址:https://www.cnblogs.com/lazy-cat-home/p/7072542.html
Copyright © 2011-2022 走看看