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

    常用的匹配语法

     

  • 相关阅读:
    Flash特效 嘿嘿
    惨,被骗了20年
    “不允许对64位应用程序进行修改”的解决方法 “Changes to 64bit applications are not allowed.”
    清除Sql Server数据库日志
    .Net 序列化(去除默认命名空间,添加编码)
    【Vegas原创】X connection to localhost:11.0 broken (explicit kill or server shutdown)解决方法
    【Vegas原创】通过WMIC命令远程打开远程计算机的远程桌面(Remote Desktop)功能
    【Vegas原创】ORA12638: 身份证明检索失败的解决办法
    【Vegas原创】SQL Server 阻止了对组件 'SQL Mail XPs' 的 过程'sys.xp_sendmail' 的访问的解决方法
    【Vegas原创】获取SQL Server处理语句的时间(毫秒)
  • 原文地址:https://www.cnblogs.com/lazy-cat-home/p/7072542.html
Copyright © 2020-2023  润新知