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模块是正则表达式模块,用来匹配一些特定的字符串。
    常用的正则表达式符号

    常用的匹配语法

     

  • 相关阅读:
    图书管理系统---基于form组件和modelform改造添加和编辑
    Keepalived和Heartbeat
    SCAN IP 解释
    Configure Active DataGuard and DG BROKER
    Oracle 11gR2
    我在管理工作中積累的九種最重要的領導力 (李開復)
    公募基金公司超融合基础架构与同城灾备建设实践
    Oracle 11g RAC for LINUX rhel 6.X silent install(静默安装)
    11gR2 静默安装RAC 集群和数据库软件
    Setting Up Oracle GoldenGate 12
  • 原文地址:https://www.cnblogs.com/lazy-cat-home/p/7072542.html
Copyright © 2011-2022 走看看